updatePolicy method
Creates or updates a project's policy, and returns a copy of the new policy.
A policy is always updated as a whole, to avoid race conditions with
concurrent policy enforcement (or management!) requests. Returns
NOT_FOUND
if the project does not exist, INVALID_ARGUMENT
if the
request is malformed.
request
- The metadata request object.
Request parameters:
name
- Output only. The resource name, in the format projects / * /policy
. There is at most one policy per project.
Value must have pattern ^projects/\[^/\]+/policy$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Policy.
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<Policy> updatePolicy(
Policy request,
core.String name, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$name');
final response_ = await _requester.request(
url_,
'PUT',
body: body_,
queryParams: queryParams_,
);
return Policy.fromJson(response_ as core.Map<core.String, core.dynamic>);
}