getIamPolicy method
Gets the IAM policy that is attached to a ServiceAccount.
This IAM policy specifies which principals have access to the service
account. This method does not tell you whether the service account has
been granted any roles on other resources. To check whether a service
account has role grants on a resource, use the getIamPolicy
method for
that resource. For example, to view the role grants for a project, call
the Resource Manager API's
projects.getIamPolicy
method.
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/\[^/\]+/serviceAccounts/\[^/\]+$
.
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 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_ = 'v1/' + core.Uri.encodeFull('$resource') + ':getIamPolicy';
final response_ = await _requester.request(
url_,
'POST',
queryParams: queryParams_,
);
return Policy.fromJson(response_ as core.Map<core.String, core.dynamic>);
}