getIamPolicy method

Future<Policy> getIamPolicy(
  1. String resource, {
  2. int? options_requestedPolicyVersion,
  3. String? $fields,
})

Gets the access control policy for a resource.

Returns an empty policy if the resource exists and does not have a policy set.

Request parameters:

resource - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/internalRanges/\[^/\]+$.

options_requestedPolicyVersion - Optional. The policy format version to be returned. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional bindings must specify version 3. Policies without any conditional bindings may specify any valid value or leave the field unset. To learn which resources support conditions in their IAM policies, see the IAM documentation.

$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> getIamPolicy(
  core.String resource, {
  core.int? options_requestedPolicyVersion,
  core.String? $fields,
}) async {
  final _queryParams = <core.String, core.List<core.String>>{
    if (options_requestedPolicyVersion != null)
      'options.requestedPolicyVersion': ['${options_requestedPolicyVersion}'],
    if ($fields != null) 'fields': [$fields],
  };

  final _url =
      'v1alpha1/' + core.Uri.encodeFull('$resource') + ':getIamPolicy';

  final _response = await _requester.request(
    _url,
    'GET',
    queryParams: _queryParams,
  );
  return Policy.fromJson(_response as core.Map<core.String, core.dynamic>);
}