getIamPolicy method

Future<ApigatewayPolicy> 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 Resource names for the appropriate value for this field. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/gateways/\[^/\]+$.

options_requestedPolicyVersion - Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. 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 ApigatewayPolicy.

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<ApigatewayPolicy> 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_ = 'v1/' + core.Uri.encodeFull('$resource') + ':getIamPolicy';

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