I'm trying to use the following API: https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.accessLevels/patch
My goal is simple: update ("patch") an "AccessLevel" object in GCP's backend.
I am calling the API using "UrlFetchApp.fetch" method from Google's Apps Script:
var result = UrlFetchApp.fetch('https://accesscontextmanager.googleapis.com/v1/accessPolicies/12345678/accessLevels/User_A_Home_IP?updateMask=updateMask',options);
where "options" (passed as the 2nd param after the url endpoint) is:
var options =
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken(),
'Content-Type' : 'application/json',
},
payload : JSON.stringify(payload),
muteHttpExceptions : true,
"updateMask" : "*"
}
and "payload" is:
var payload=
{
"basic": {
"combiningFunction": "OR",
"conditions": [
{
"ipSubnetworks": [
"11.12.13.14/32"
]
}
]
},
"name": "accessPolicies/12345678/accessLevels/User_A_Home_IP",
"title": "User A Home IP"
}
The result I'm getting back is:
{
"error": {
"code": 400,
"message": "Invalid update_mask. All paths must be in the AccessLevel message.",
"status": "INVALID_ARGUMENT"
}
}
According to the documentation (first link in this post) The request body should contain an instance of AccessLevel (this is the "payload" object in my code) Also required is an "updateMask" query parameter which indicates which fields of the backend target json object get updated.
updateMask, If I understand correctly - is of Type FieldMask: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask
I only need to update the single IP address found in the "ipSubnetworks" array of strings, that in turn is found inside the "conditions" array of objects, which in turn is nested under the "basic" object.
What is the correct syntax for updateMask in this case?
Where should updateMask be located in my "PATCH" request?