patch method

Future<GoogleCloudOrgpolicyV2Policy> patch(
  1. GoogleCloudOrgpolicyV2Policy request,
  2. String name, {
  3. String? updateMask,
  4. String? $fields,
})

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.

request - The metadata request object.

Request parameters:

name - Immutable. The resource name of the policy. Must be one of the following forms, where constraint_name is the name of the constraint which this policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, projects/123/policies/compute.disableSerialPortAccess. Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number. Value must have pattern ^organizations/\[^/\]+/policies/\[^/\]+$.

updateMask - Field mask used to specify the fields to be overwritten in the policy by the set. The fields specified in the update_mask are relative to the policy, not the full request.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GoogleCloudOrgpolicyV2Policy.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GoogleCloudOrgpolicyV2Policy> patch(
  GoogleCloudOrgpolicyV2Policy request,
  core.String name, {
  core.String? updateMask,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (updateMask != null) 'updateMask': [updateMask],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$name');

  final response_ = await _requester.request(
    url_,
    'PATCH',
    body: body_,
    queryParams: queryParams_,
  );
  return GoogleCloudOrgpolicyV2Policy.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}