IAM¶
- class google.cloud.iam_admin_v1.services.iam.IAMAsyncClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport, typing.Callable[[...], google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport]]] = 'grpc_asyncio', client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]¶
Creates and manages Identity and Access Management (IAM) resources.
You can use this service to work with all of the following resources:
Service accounts, which identify an application or a virtual machine (VM) instance rather than a person
Service account keys, which service accounts use to authenticate with Google APIs
IAM policies for service accounts, which specify the roles that a principal has for the service account
IAM custom roles, which help you limit the number of permissions that you grant to principals
In addition, you can use this service to complete the following tasks, among others:
Test whether a service account can use specific permissions
Check which roles you can grant for a specific resource
Lint, or validate, condition expressions in an IAM policy
When you read data from the IAM API, each read is eventually consistent. In other words, if you write data with the IAM API, then immediately read that data, the read operation might return an older version of the data. To deal with this behavior, your application can retry the request with truncated exponential backoff.
In contrast, writing data to the IAM API is sequentially consistent. In other words, write operations are always processed in the order in which they were received.
Instantiates the iam async client.
- Parameters
credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.
transport (Optional[Union[str,IAMTransport,Callable[..., IAMTransport]]]) – The transport to use, or a Callable that constructs and returns a new transport to use. If a Callable is given, it will be called with the same set of initialization arguments as used in the IAMTransport constructor. If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]) –
Custom options for the client.
1. The
api_endpoint
property can be used to override the default endpoint provided by the client whentransport
is not explicitly provided. Only if this property is not set andtransport
was not explicitly provided, the endpoint is determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment variable, which have one of the following values: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto-switch to the default mTLS endpoint if client certificate is present; this is the default value).2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the
client_cert_source
property can be used to provide a client certificate for mTLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.3. The
universe_domain
property can be used to override the default “googleapis.com” universe. Note thatapi_endpoint
property still takes precedence; anduniverse_domain
is currently not supported for mTLS.client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If
None
, then default info will be used. Generally, you only need to set this if you’re developing your own client library.
- Raises
google.auth.exceptions.MutualTlsChannelError – If mutual TLS transport creation failed for any reason.
- property api_endpoint¶
Return the API endpoint used by the client instance.
- Returns
The API endpoint used by the client instance.
- Return type
- static common_billing_account_path(billing_account: str) str ¶
Returns a fully-qualified billing_account string.
- static common_location_path(project: str, location: str) str ¶
Returns a fully-qualified location string.
- static common_organization_path(organization: str) str ¶
Returns a fully-qualified organization string.
- async create_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Creates a new custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_create_role(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.CreateRoleRequest( ) # Make the request response = await client.create_role(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.CreateRoleRequest, dict]]) – The request object. The request to create a new role.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- async create_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, account_id: Optional[str] = None, service_account: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccount] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Creates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_create_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.CreateServiceAccountRequest( name="name_value", account_id="account_id_value", ) # Make the request response = await client.create_service_account(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.CreateServiceAccountRequest, dict]]) – The request object. The service account create request.
name (
str
) –Required. The resource name of the project associated with the service accounts, such as
projects/my-project-123
.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.account_id (
str
) –Required. The account id that is used to generate the service account email address and a stable unique id. It is unique within a project, must be 6-30 characters long, and match the regular expression
[a-z]([-a-z0-9]*[a-z0-9])
to comply with RFC1035.This corresponds to the
account_id
field on therequest
instance; ifrequest
is provided, this should not be set.service_account (
google.cloud.iam_admin_v1.types.ServiceAccount
) –The [ServiceAccount][google.iam.admin.v1.ServiceAccount] resource to create. Currently, only the following values are user assignable:
display_name
anddescription
.This corresponds to the
service_account
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- async create_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, private_key_type: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountPrivateKeyType] = None, key_algorithm: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountKeyAlgorithm] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Creates a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_create_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.CreateServiceAccountKeyRequest( name="name_value", ) # Make the request response = await client.create_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.CreateServiceAccountKeyRequest, dict]]) – The request object. The service account key create request.
name (
str
) –Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.private_key_type (
google.cloud.iam_admin_v1.types.ServiceAccountPrivateKeyType
) –The output format of the private key. The default value is
TYPE_GOOGLE_CREDENTIALS_FILE
, which is the Google Credentials File format.This corresponds to the
private_key_type
field on therequest
instance; ifrequest
is provided, this should not be set.key_algorithm (
google.cloud.iam_admin_v1.types.ServiceAccountKeyAlgorithm
) –Which type of key and algorithm to use for the key. The default is currently a 2K RSA key. However this may change in the future.
This corresponds to the
key_algorithm
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- async delete_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Deletes a custom [Role][google.iam.admin.v1.Role].
When you delete a custom role, the following changes occur immediately:
You cannot bind a principal to the custom role in an IAM [Policy][google.iam.v1.Policy].
Existing bindings to the custom role are not changed, but they have no effect.
By default, the response from [ListRoles][google.iam.admin.v1.IAM.ListRoles] does not include the custom role.
You have 7 days to undelete the custom role. After 7 days, the following changes occur:
The custom role is permanently deleted and cannot be recovered.
If an IAM policy contains a binding to the custom role, the binding is permanently removed.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_delete_role(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.DeleteRoleRequest( ) # Make the request response = await client.delete_role(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.DeleteRoleRequest, dict]]) – The request object. The request to delete an existing role.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- async delete_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Deletes a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Warning: After you delete a service account, you might not be able to undelete it. If you know that you need to re-enable the service account in the future, use [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount] instead.
If you delete a service account, IAM permanently removes the service account 30 days later. Google Cloud cannot recover the service account after it is permanently removed, even if you file a support request.
To help avoid unplanned outages, we recommend that you disable the service account before you delete it. Use [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount] to disable the service account, then wait at least 24 hours and watch for unintended consequences. If there are no unintended consequences, you can delete the service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_delete_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.DeleteServiceAccountRequest( name="name_value", ) # Make the request await client.delete_service_account(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.DeleteServiceAccountRequest, dict]]) – The request object. The service account delete request.
name (
str
) –Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async delete_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Deletes a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]. Deleting a service account key does not revoke short-lived credentials that have been issued based on the service account key.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_delete_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.DeleteServiceAccountKeyRequest( name="name_value", ) # Make the request await client.delete_service_account_key(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.DeleteServiceAccountKeyRequest, dict]]) – The request object. The service account key delete request.
name (
str
) –Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async disable_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DisableServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Disables a [ServiceAccount][google.iam.admin.v1.ServiceAccount] immediately.
If an application uses the service account to authenticate, that application can no longer call Google APIs or access Google Cloud resources. Existing access tokens for the service account are rejected, and requests for new access tokens will fail.
To re-enable the service account, use [EnableServiceAccount][google.iam.admin.v1.IAM.EnableServiceAccount]. After you re-enable the service account, its existing access tokens will be accepted, and you can request new access tokens.
To help avoid unplanned outages, we recommend that you disable the service account before you delete it. Use this method to disable the service account, then wait at least 24 hours and watch for unintended consequences. If there are no unintended consequences, you can delete the service account with [DeleteServiceAccount][google.iam.admin.v1.IAM.DeleteServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_disable_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.DisableServiceAccountRequest( ) # Make the request await client.disable_service_account(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.DisableServiceAccountRequest, dict]]) – The request object. The service account disable request.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async disable_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DisableServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Disable a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]. A disabled service account key can be re-enabled with [EnableServiceAccountKey][google.iam.admin.v1.IAM.EnableServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_disable_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.DisableServiceAccountKeyRequest( name="name_value", ) # Make the request await client.disable_service_account_key(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.DisableServiceAccountKeyRequest, dict]]) – The request object. The service account key disable request.
name (
str
) –Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async enable_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.EnableServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Enables a [ServiceAccount][google.iam.admin.v1.ServiceAccount] that was disabled by [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount].
If the service account is already enabled, then this method has no effect.
If the service account was disabled by other means—for example, if Google disabled the service account because it was compromised—you cannot use this method to enable the service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_enable_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.EnableServiceAccountRequest( ) # Make the request await client.enable_service_account(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.EnableServiceAccountRequest, dict]]) – The request object. The service account enable request.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async enable_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.EnableServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Enable a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_enable_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.EnableServiceAccountKeyRequest( name="name_value", ) # Make the request await client.enable_service_account_key(request=request)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.EnableServiceAccountKeyRequest, dict]]) – The request object. The service account key enable request.
name (
str
) –Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- classmethod from_service_account_file(filename: str, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_info(info: dict, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
info.
- Parameters
info (dict) – The service account private key info.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_json(filename: str, *args, **kwargs)¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- async get_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Gets the IAM policy that is attached to a [ServiceAccount][google.iam.admin.v1.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
<https://cloud.google.com/resource-manager/reference/rest/v1/projects/getIamPolicy>`__ method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request response = await client.get_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]) – The request object. Request message for
GetIamPolicy
method.resource (
str
) –REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- classmethod get_mtls_endpoint_and_cert_source(client_options: Optional[google.api_core.client_options.ClientOptions] = None)[source]¶
Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not “true”, the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.
The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “always”, use the default mTLS endpoint; if the environment variable is “never”, use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
- Parameters
client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. Only the api_endpoint and client_cert_source properties may be used in this method.
- Returns
- returns the API endpoint and the
client cert source to use.
- Return type
- Raises
google.auth.exceptions.MutualTLSChannelError – If any errors happen.
- async get_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Gets the definition of a [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_get_role(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.GetRoleRequest( ) # Make the request response = await client.get_role(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.GetRoleRequest, dict]]) – The request object. The request to get the definition of an existing role.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- async get_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Gets a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_get_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.GetServiceAccountRequest( name="name_value", ) # Make the request response = await client.get_service_account(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.GetServiceAccountRequest, dict]]) – The request object. The service account get request.
name (
str
) –Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- async get_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, public_key_type: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountPublicKeyType] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Gets a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_get_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.GetServiceAccountKeyRequest( name="name_value", ) # Make the request response = await client.get_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.GetServiceAccountKeyRequest, dict]]) – The request object. The service account key get by id request.
name (
str
) –Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.public_key_type (
google.cloud.iam_admin_v1.types.ServiceAccountPublicKeyType
) –Optional. The output format of the public key. The default is
TYPE_NONE
, which means that the public key is not returned.This corresponds to the
public_key_type
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- classmethod get_transport_class(label: Optional[str] = None) Type[google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport] ¶
Returns an appropriate transport class.
- Parameters
label – The name of the desired transport. If none is provided, then the first transport in the registry is used.
- Returns
The transport class to use.
- static key_path(project: str, service_account: str, key: str) str ¶
Returns a fully-qualified key string.
- async lint_policy(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.LintPolicyRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.LintPolicyResponse [source]¶
Lints, or validates, an IAM policy. Currently checks the [google.iam.v1.Binding.condition][google.iam.v1.Binding.condition] field, which contains a condition expression for a role binding.
Successful calls to this method always return an HTTP
200 OK
status code, even if the linter detects an issue in the IAM policy.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_lint_policy(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.LintPolicyRequest( ) # Make the request response = await client.lint_policy(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.LintPolicyRequest, dict]]) – The request object. The request to lint a Cloud IAM policy object.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response of a lint operation. An empty response indicates the operation was able to fully execute and no lint issue was found.
- Return type
- async list_roles(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListRolesRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.ListRolesAsyncPager [source]¶
Lists every predefined [Role][google.iam.admin.v1.Role] that IAM supports, or every custom role that is defined for an organization or project.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_list_roles(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.ListRolesRequest( ) # Make the request page_result = client.list_roles(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.ListRolesRequest, dict]]) – The request object. The request to get all roles defined under a resource.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response containing the roles defined under a resource. Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.ListRolesAsyncPager
- async list_service_account_keys(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysRequest, dict]] = None, *, name: Optional[str] = None, key_types: Optional[MutableSequence[google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysRequest.KeyType]] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysResponse [source]¶
Lists every [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey] for a service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_list_service_account_keys(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.ListServiceAccountKeysRequest( name="name_value", ) # Make the request response = await client.list_service_account_keys(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.ListServiceAccountKeysRequest, dict]]) – The request object. The service account keys list request.
name (
str
) –Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
.Using
-
as a wildcard for thePROJECT_ID
, will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.key_types (
MutableSequence[google.cloud.iam_admin_v1.types.ListServiceAccountKeysRequest.KeyType]
) –Filters the types of keys the user wants to include in the list response. Duplicate key types are not allowed. If no key type is provided, all keys are returned.
This corresponds to the
key_types
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The service account keys list response.
- Return type
google.cloud.iam_admin_v1.types.ListServiceAccountKeysResponse
- async list_service_accounts(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListServiceAccountsRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsAsyncPager [source]¶
Lists every [ServiceAccount][google.iam.admin.v1.ServiceAccount] that belongs to a specific project.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_list_service_accounts(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.ListServiceAccountsRequest( name="name_value", ) # Make the request page_result = client.list_service_accounts(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.ListServiceAccountsRequest, dict]]) – The request object. The service account list request.
name (
str
) –Required. The resource name of the project associated with the service accounts, such as
projects/my-project-123
.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The service account list response.
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsAsyncPager
- static parse_common_billing_account_path(path: str) Dict[str, str] ¶
Parse a billing_account path into its component segments.
- static parse_common_folder_path(path: str) Dict[str, str] ¶
Parse a folder path into its component segments.
- static parse_common_location_path(path: str) Dict[str, str] ¶
Parse a location path into its component segments.
- static parse_common_organization_path(path: str) Dict[str, str] ¶
Parse a organization path into its component segments.
- static parse_common_project_path(path: str) Dict[str, str] ¶
Parse a project path into its component segments.
- static parse_service_account_path(path: str) Dict[str, str] ¶
Parses a service_account path into its component segments.
- async patch_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.PatchServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Patches a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_patch_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.PatchServiceAccountRequest( ) # Make the request response = await client.patch_service_account(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.PatchServiceAccountRequest, dict]]) –
The request object. The service account patch request.
You can patch only the
display_name
anddescription
fields. You must use theupdate_mask
field to specify which of these fields you want to patch.Only the fields specified in the request are guaranteed to be returned in the response. Other fields may be empty in the response.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- async query_auditable_services(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryAuditableServicesRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.QueryAuditableServicesResponse [source]¶
Returns a list of services that allow you to opt into audit logs that are not generated by default.
To learn more about audit logs, see the Logging documentation.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_query_auditable_services(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.QueryAuditableServicesRequest( ) # Make the request response = await client.query_auditable_services(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.QueryAuditableServicesRequest, dict]]) – The request object. A request to get the list of auditable services for a resource.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A response containing a list of auditable services for a resource.
- Return type
google.cloud.iam_admin_v1.types.QueryAuditableServicesResponse
- async query_grantable_roles(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesRequest, dict]] = None, *, full_resource_name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesAsyncPager [source]¶
Lists roles that can be granted on a Google Cloud resource. A role is grantable if the IAM policy for the resource can contain bindings to the role.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_query_grantable_roles(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.QueryGrantableRolesRequest( full_resource_name="full_resource_name_value", ) # Make the request page_result = client.query_grantable_roles(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.QueryGrantableRolesRequest, dict]]) – The request object. The grantable role query request.
full_resource_name (
str
) –Required. The full resource name to query from the list of grantable roles.
The name follows the Google Cloud Platform resource format. For example, a Cloud Platform project with id
my-project
will be named//cloudresourcemanager.googleapis.com/projects/my-project
.This corresponds to the
full_resource_name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The grantable role query response.
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesAsyncPager
- async query_testable_permissions(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsAsyncPager [source]¶
Lists every permission that you can test on a resource. A permission is testable if you can check whether a principal has that permission on the resource.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_query_testable_permissions(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.QueryTestablePermissionsRequest( ) # Make the request page_result = client.query_testable_permissions(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.QueryTestablePermissionsRequest, dict]]) – The request object. A request to get permissions which can be tested on a resource.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response containing permissions which can be tested on a resource. Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsAsyncPager
- static service_account_path(project: str, service_account: str) str ¶
Returns a fully-qualified service_account string.
- async set_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Sets the IAM policy that is attached to a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Use this method to grant or revoke access to the service account. For example, you could grant a principal the ability to impersonate the service account.
This method does not enable the service account to access other resources. To grant roles to a service account on a resource, follow these steps:
Call the resource’s
getIamPolicy
method to get its current IAM policy.Edit the policy so that it binds the service account to an IAM role for the resource.
Call the resource’s
setIamPolicy
method to update its IAM policy.
For detailed instructions, see Manage access to project, folders, and organizations or Manage access to other resources.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request response = await client.set_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]) – The request object. Request message for
SetIamPolicy
method.resource (
str
) –REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- async sign_blob(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.SignBlobRequest, dict]] = None, *, name: Optional[str] = None, bytes_to_sign: Optional[bytes] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.SignBlobResponse [source]¶
Note: This method is deprecated. Use the
`signBlob
<https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signBlob>`__ method in the IAM Service Account Credentials API instead. If you currently use this method, see the migration guide for instructions.Signs a blob using the system-managed private key for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_sign_blob(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.SignBlobRequest( name="name_value", bytes_to_sign=b'bytes_to_sign_blob', ) # Make the request response = await client.sign_blob(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.SignBlobRequest, dict]]) –
The request object. Deprecated. Migrate to Service Account Credentials API.
The service account sign blob request.
name (
str
) –Required. Deprecated. Migrate to Service Account Credentials API.
The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.bytes_to_sign (
bytes
) –Required. Deprecated. Migrate to Service Account Credentials API.
The bytes to sign.
This corresponds to the
bytes_to_sign
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Deprecated. [Migrate to Service Account Credentials
API](https://cloud.google.com/iam/help/credentials/migrate-api).
The service account sign blob response.
- Return type
- async sign_jwt(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.SignJwtRequest, dict]] = None, *, name: Optional[str] = None, payload: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.SignJwtResponse [source]¶
Note: This method is deprecated. Use the
`signJwt
<https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signJwt>`__ method in the IAM Service Account Credentials API instead. If you currently use this method, see the migration guide for instructions.Signs a JSON Web Token (JWT) using the system-managed private key for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_sign_jwt(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.SignJwtRequest( name="name_value", payload="payload_value", ) # Make the request response = await client.sign_jwt(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.SignJwtRequest, dict]]) –
The request object. Deprecated. Migrate to Service Account Credentials API.
The service account sign JWT request.
name (
str
) –Required. Deprecated. Migrate to Service Account Credentials API.
The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.payload (
str
) –Required. Deprecated. Migrate to Service Account Credentials API.
The JWT payload to sign. Must be a serialized JSON object that contains a JWT Claims Set. For example:
{"sub": "user@example.com", "iat": 313435}
If the JWT Claims Set contains an expiration time (
exp
) claim, it must be an integer timestamp that is not in the past and no more than 12 hours in the future.If the JWT Claims Set does not contain an expiration time (
exp
) claim, this claim is added automatically, with a timestamp that is 1 hour in the future.This corresponds to the
payload
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Deprecated. [Migrate to Service Account Credentials
API](https://cloud.google.com/iam/help/credentials/migrate-api).
The service account sign JWT response.
- Return type
- async test_iam_permissions(request: Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, resource: Optional[str] = None, permissions: Optional[MutableSequence[str]] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse [source]¶
Tests whether the caller has the specified permissions on a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value1', 'permissions_value2'], ) # Make the request response = await client.test_iam_permissions(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]) – The request object. Request message for
TestIamPermissions
method.resource (
str
) –REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.permissions (
MutableSequence[str]
) –The set of permissions to check for the
resource
. Permissions with wildcards (such as ‘*’ or ‘storage.*’) are not allowed. For more information see IAM Overview.This corresponds to the
permissions
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for TestIamPermissions method.
- Return type
google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse
- property transport: google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport¶
Returns the transport used by the client instance.
- Returns
The transport used by the client instance.
- Return type
IAMTransport
- async undelete_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UndeleteRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Undeletes a custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_undelete_role(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.UndeleteRoleRequest( ) # Make the request response = await client.undelete_role(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.UndeleteRoleRequest, dict]]) – The request object. The request to undelete an existing role.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- async undelete_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UndeleteServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.UndeleteServiceAccountResponse [source]¶
Restores a deleted [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Important: It is not always possible to restore a deleted service account. Use this method only as a last resort.
After you delete a service account, IAM permanently removes the service account 30 days later. There is no way to restore a deleted service account that has been permanently removed.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_undelete_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.UndeleteServiceAccountRequest( ) # Make the request response = await client.undelete_service_account(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.UndeleteServiceAccountRequest, dict]]) – The request object. The service account undelete request.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Return type
google.cloud.iam_admin_v1.types.UndeleteServiceAccountResponse
- property universe_domain: str¶
Return the universe domain used by the client instance.
- Returns
- The universe domain used
by the client instance.
- Return type
- async update_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UpdateRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Updates the definition of a custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_update_role(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.UpdateRoleRequest( ) # Make the request response = await client.update_role(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.UpdateRoleRequest, dict]]) – The request object. The request to update a role.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- async update_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ServiceAccount, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Note: We are in the process of deprecating this method. Use [PatchServiceAccount][google.iam.admin.v1.IAM.PatchServiceAccount] instead.
Updates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
You can update only the
display_name
field.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_update_service_account(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.ServiceAccount( ) # Make the request response = await client.update_service_account(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.ServiceAccount, dict]]) –
The request object. An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the overview of service accounts.
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- async upload_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UploadServiceAccountKeyRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Uploads the public key portion of a key pair that you manage, and associates the public key with a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
After you upload the public key, you can use the private key from the key pair as a service account key.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 async def sample_upload_service_account_key(): # Create a client client = iam_admin_v1.IAMAsyncClient() # Initialize request argument(s) request = iam_admin_v1.UploadServiceAccountKeyRequest( ) # Make the request response = await client.upload_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.iam_admin_v1.types.UploadServiceAccountKeyRequest, dict]]) – The request object. The service account key upload request.
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- class google.cloud.iam_admin_v1.services.iam.IAMClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport, typing.Callable[[...], google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport]]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]¶
Creates and manages Identity and Access Management (IAM) resources.
You can use this service to work with all of the following resources:
Service accounts, which identify an application or a virtual machine (VM) instance rather than a person
Service account keys, which service accounts use to authenticate with Google APIs
IAM policies for service accounts, which specify the roles that a principal has for the service account
IAM custom roles, which help you limit the number of permissions that you grant to principals
In addition, you can use this service to complete the following tasks, among others:
Test whether a service account can use specific permissions
Check which roles you can grant for a specific resource
Lint, or validate, condition expressions in an IAM policy
When you read data from the IAM API, each read is eventually consistent. In other words, if you write data with the IAM API, then immediately read that data, the read operation might return an older version of the data. To deal with this behavior, your application can retry the request with truncated exponential backoff.
In contrast, writing data to the IAM API is sequentially consistent. In other words, write operations are always processed in the order in which they were received.
Instantiates the iam client.
- Parameters
credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.
transport (Optional[Union[str,IAMTransport,Callable[..., IAMTransport]]]) – The transport to use, or a Callable that constructs and returns a new transport. If a Callable is given, it will be called with the same set of initialization arguments as used in the IAMTransport constructor. If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]) –
Custom options for the client.
1. The
api_endpoint
property can be used to override the default endpoint provided by the client whentransport
is not explicitly provided. Only if this property is not set andtransport
was not explicitly provided, the endpoint is determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment variable, which have one of the following values: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto-switch to the default mTLS endpoint if client certificate is present; this is the default value).2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the
client_cert_source
property can be used to provide a client certificate for mTLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.3. The
universe_domain
property can be used to override the default “googleapis.com” universe. Note that theapi_endpoint
property still takes precedence; anduniverse_domain
is currently not supported for mTLS.client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If
None
, then default info will be used. Generally, you only need to set this if you’re developing your own client library.
- Raises
google.auth.exceptions.MutualTLSChannelError – If mutual TLS transport creation failed for any reason.
- __exit__(type, value, traceback)[source]¶
Releases underlying transport’s resources.
Warning
ONLY use as a context manager if the transport is NOT shared with other clients! Exiting the with block will CLOSE the transport and may cause errors in other clients!
- property api_endpoint¶
Return the API endpoint used by the client instance.
- Returns
The API endpoint used by the client instance.
- Return type
- static common_billing_account_path(billing_account: str) str [source]¶
Returns a fully-qualified billing_account string.
- static common_location_path(project: str, location: str) str [source]¶
Returns a fully-qualified location string.
- static common_organization_path(organization: str) str [source]¶
Returns a fully-qualified organization string.
- create_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Creates a new custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_create_role(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.CreateRoleRequest( ) # Make the request response = client.create_role(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.CreateRoleRequest, dict]) – The request object. The request to create a new role.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- create_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, account_id: Optional[str] = None, service_account: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccount] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Creates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_create_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.CreateServiceAccountRequest( name="name_value", account_id="account_id_value", ) # Make the request response = client.create_service_account(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.CreateServiceAccountRequest, dict]) – The request object. The service account create request.
name (str) –
Required. The resource name of the project associated with the service accounts, such as
projects/my-project-123
.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.account_id (str) –
Required. The account id that is used to generate the service account email address and a stable unique id. It is unique within a project, must be 6-30 characters long, and match the regular expression
[a-z]([-a-z0-9]*[a-z0-9])
to comply with RFC1035.This corresponds to the
account_id
field on therequest
instance; ifrequest
is provided, this should not be set.service_account (google.cloud.iam_admin_v1.types.ServiceAccount) –
The [ServiceAccount][google.iam.admin.v1.ServiceAccount] resource to create. Currently, only the following values are user assignable:
display_name
anddescription
.This corresponds to the
service_account
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- create_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.CreateServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, private_key_type: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountPrivateKeyType] = None, key_algorithm: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountKeyAlgorithm] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Creates a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_create_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.CreateServiceAccountKeyRequest( name="name_value", ) # Make the request response = client.create_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.CreateServiceAccountKeyRequest, dict]) – The request object. The service account key create request.
name (str) –
Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.private_key_type (google.cloud.iam_admin_v1.types.ServiceAccountPrivateKeyType) –
The output format of the private key. The default value is
TYPE_GOOGLE_CREDENTIALS_FILE
, which is the Google Credentials File format.This corresponds to the
private_key_type
field on therequest
instance; ifrequest
is provided, this should not be set.key_algorithm (google.cloud.iam_admin_v1.types.ServiceAccountKeyAlgorithm) –
Which type of key and algorithm to use for the key. The default is currently a 2K RSA key. However this may change in the future.
This corresponds to the
key_algorithm
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- delete_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Deletes a custom [Role][google.iam.admin.v1.Role].
When you delete a custom role, the following changes occur immediately:
You cannot bind a principal to the custom role in an IAM [Policy][google.iam.v1.Policy].
Existing bindings to the custom role are not changed, but they have no effect.
By default, the response from [ListRoles][google.iam.admin.v1.IAM.ListRoles] does not include the custom role.
You have 7 days to undelete the custom role. After 7 days, the following changes occur:
The custom role is permanently deleted and cannot be recovered.
If an IAM policy contains a binding to the custom role, the binding is permanently removed.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_delete_role(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.DeleteRoleRequest( ) # Make the request response = client.delete_role(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.DeleteRoleRequest, dict]) – The request object. The request to delete an existing role.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- delete_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Deletes a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Warning: After you delete a service account, you might not be able to undelete it. If you know that you need to re-enable the service account in the future, use [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount] instead.
If you delete a service account, IAM permanently removes the service account 30 days later. Google Cloud cannot recover the service account after it is permanently removed, even if you file a support request.
To help avoid unplanned outages, we recommend that you disable the service account before you delete it. Use [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount] to disable the service account, then wait at least 24 hours and watch for unintended consequences. If there are no unintended consequences, you can delete the service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_delete_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.DeleteServiceAccountRequest( name="name_value", ) # Make the request client.delete_service_account(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.DeleteServiceAccountRequest, dict]) – The request object. The service account delete request.
name (str) –
Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- delete_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DeleteServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Deletes a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]. Deleting a service account key does not revoke short-lived credentials that have been issued based on the service account key.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_delete_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.DeleteServiceAccountKeyRequest( name="name_value", ) # Make the request client.delete_service_account_key(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.DeleteServiceAccountKeyRequest, dict]) – The request object. The service account key delete request.
name (str) –
Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- disable_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DisableServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Disables a [ServiceAccount][google.iam.admin.v1.ServiceAccount] immediately.
If an application uses the service account to authenticate, that application can no longer call Google APIs or access Google Cloud resources. Existing access tokens for the service account are rejected, and requests for new access tokens will fail.
To re-enable the service account, use [EnableServiceAccount][google.iam.admin.v1.IAM.EnableServiceAccount]. After you re-enable the service account, its existing access tokens will be accepted, and you can request new access tokens.
To help avoid unplanned outages, we recommend that you disable the service account before you delete it. Use this method to disable the service account, then wait at least 24 hours and watch for unintended consequences. If there are no unintended consequences, you can delete the service account with [DeleteServiceAccount][google.iam.admin.v1.IAM.DeleteServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_disable_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.DisableServiceAccountRequest( ) # Make the request client.disable_service_account(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.DisableServiceAccountRequest, dict]) – The request object. The service account disable request.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- disable_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.DisableServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Disable a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]. A disabled service account key can be re-enabled with [EnableServiceAccountKey][google.iam.admin.v1.IAM.EnableServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_disable_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.DisableServiceAccountKeyRequest( name="name_value", ) # Make the request client.disable_service_account_key(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.DisableServiceAccountKeyRequest, dict]) – The request object. The service account key disable request.
name (str) –
Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- enable_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.EnableServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Enables a [ServiceAccount][google.iam.admin.v1.ServiceAccount] that was disabled by [DisableServiceAccount][google.iam.admin.v1.IAM.DisableServiceAccount].
If the service account is already enabled, then this method has no effect.
If the service account was disabled by other means—for example, if Google disabled the service account because it was compromised—you cannot use this method to enable the service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_enable_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.EnableServiceAccountRequest( ) # Make the request client.enable_service_account(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.EnableServiceAccountRequest, dict]) – The request object. The service account enable request.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- enable_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.EnableServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Enable a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_enable_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.EnableServiceAccountKeyRequest( name="name_value", ) # Make the request client.enable_service_account_key(request=request)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.EnableServiceAccountKeyRequest, dict]) – The request object. The service account key enable request.
name (str) –
Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- classmethod from_service_account_file(filename: str, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
file.
- classmethod from_service_account_info(info: dict, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
info.
- classmethod from_service_account_json(filename: str, *args, **kwargs)¶
- Creates an instance of this client using the provided credentials
file.
- get_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Gets the IAM policy that is attached to a [ServiceAccount][google.iam.admin.v1.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
<https://cloud.google.com/resource-manager/reference/rest/v1/projects/getIamPolicy>`__ method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request response = client.get_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]) – The request object. Request message for
GetIamPolicy
method.resource (str) –
REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- classmethod get_mtls_endpoint_and_cert_source(client_options: Optional[google.api_core.client_options.ClientOptions] = None)[source]¶
Deprecated. Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not “true”, the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.
The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “always”, use the default mTLS endpoint; if the environment variable is “never”, use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
- Parameters
client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. Only the api_endpoint and client_cert_source properties may be used in this method.
- Returns
- returns the API endpoint and the
client cert source to use.
- Return type
- Raises
google.auth.exceptions.MutualTLSChannelError – If any errors happen.
- get_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Gets the definition of a [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_get_role(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.GetRoleRequest( ) # Make the request response = client.get_role(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.GetRoleRequest, dict]) – The request object. The request to get the definition of an existing role.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- get_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetServiceAccountRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Gets a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_get_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.GetServiceAccountRequest( name="name_value", ) # Make the request response = client.get_service_account(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.GetServiceAccountRequest, dict]) – The request object. The service account get request.
name (str) –
Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- get_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.GetServiceAccountKeyRequest, dict]] = None, *, name: Optional[str] = None, public_key_type: Optional[google.cloud.iam_admin_v1.types.iam.ServiceAccountPublicKeyType] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Gets a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_get_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.GetServiceAccountKeyRequest( name="name_value", ) # Make the request response = client.get_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.GetServiceAccountKeyRequest, dict]) – The request object. The service account key get by id request.
name (str) –
Required. The resource name of the service account key in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}
.Using
-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.public_key_type (google.cloud.iam_admin_v1.types.ServiceAccountPublicKeyType) –
Optional. The output format of the public key. The default is
TYPE_NONE
, which means that the public key is not returned.This corresponds to the
public_key_type
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- static key_path(project: str, service_account: str, key: str) str [source]¶
Returns a fully-qualified key string.
- lint_policy(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.LintPolicyRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.LintPolicyResponse [source]¶
Lints, or validates, an IAM policy. Currently checks the [google.iam.v1.Binding.condition][google.iam.v1.Binding.condition] field, which contains a condition expression for a role binding.
Successful calls to this method always return an HTTP
200 OK
status code, even if the linter detects an issue in the IAM policy.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_lint_policy(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.LintPolicyRequest( ) # Make the request response = client.lint_policy(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.LintPolicyRequest, dict]) – The request object. The request to lint a Cloud IAM policy object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response of a lint operation. An empty response indicates the operation was able to fully execute and no lint issue was found.
- Return type
- list_roles(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListRolesRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.ListRolesPager [source]¶
Lists every predefined [Role][google.iam.admin.v1.Role] that IAM supports, or every custom role that is defined for an organization or project.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_list_roles(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.ListRolesRequest( ) # Make the request page_result = client.list_roles(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.ListRolesRequest, dict]) – The request object. The request to get all roles defined under a resource.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response containing the roles defined under a resource. Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.ListRolesPager
- list_service_account_keys(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysRequest, dict]] = None, *, name: Optional[str] = None, key_types: Optional[MutableSequence[google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysRequest.KeyType]] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ListServiceAccountKeysResponse [source]¶
Lists every [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey] for a service account.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_list_service_account_keys(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.ListServiceAccountKeysRequest( name="name_value", ) # Make the request response = client.list_service_account_keys(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.ListServiceAccountKeysRequest, dict]) – The request object. The service account keys list request.
name (str) –
Required. The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
.Using
-
as a wildcard for thePROJECT_ID
, will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.key_types (MutableSequence[google.cloud.iam_admin_v1.types.ListServiceAccountKeysRequest.KeyType]) –
Filters the types of keys the user wants to include in the list response. Duplicate key types are not allowed. If no key type is provided, all keys are returned.
This corresponds to the
key_types
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The service account keys list response.
- Return type
google.cloud.iam_admin_v1.types.ListServiceAccountKeysResponse
- list_service_accounts(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ListServiceAccountsRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsPager [source]¶
Lists every [ServiceAccount][google.iam.admin.v1.ServiceAccount] that belongs to a specific project.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_list_service_accounts(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.ListServiceAccountsRequest( name="name_value", ) # Make the request page_result = client.list_service_accounts(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.ListServiceAccountsRequest, dict]) – The request object. The service account list request.
name (str) –
Required. The resource name of the project associated with the service accounts, such as
projects/my-project-123
.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The service account list response.
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsPager
- static parse_common_billing_account_path(path: str) Dict[str, str] [source]¶
Parse a billing_account path into its component segments.
- static parse_common_folder_path(path: str) Dict[str, str] [source]¶
Parse a folder path into its component segments.
- static parse_common_location_path(path: str) Dict[str, str] [source]¶
Parse a location path into its component segments.
- static parse_common_organization_path(path: str) Dict[str, str] [source]¶
Parse a organization path into its component segments.
- static parse_common_project_path(path: str) Dict[str, str] [source]¶
Parse a project path into its component segments.
- static parse_key_path(path: str) Dict[str, str] [source]¶
Parses a key path into its component segments.
- static parse_service_account_path(path: str) Dict[str, str] [source]¶
Parses a service_account path into its component segments.
- patch_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.PatchServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Patches a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_patch_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.PatchServiceAccountRequest( ) # Make the request response = client.patch_service_account(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.PatchServiceAccountRequest, dict]) –
The request object. The service account patch request.
You can patch only the
display_name
anddescription
fields. You must use theupdate_mask
field to specify which of these fields you want to patch.Only the fields specified in the request are guaranteed to be returned in the response. Other fields may be empty in the response.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- query_auditable_services(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryAuditableServicesRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.QueryAuditableServicesResponse [source]¶
Returns a list of services that allow you to opt into audit logs that are not generated by default.
To learn more about audit logs, see the Logging documentation.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_query_auditable_services(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.QueryAuditableServicesRequest( ) # Make the request response = client.query_auditable_services(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.QueryAuditableServicesRequest, dict]) – The request object. A request to get the list of auditable services for a resource.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A response containing a list of auditable services for a resource.
- Return type
google.cloud.iam_admin_v1.types.QueryAuditableServicesResponse
- query_grantable_roles(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesRequest, dict]] = None, *, full_resource_name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesPager [source]¶
Lists roles that can be granted on a Google Cloud resource. A role is grantable if the IAM policy for the resource can contain bindings to the role.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_query_grantable_roles(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.QueryGrantableRolesRequest( full_resource_name="full_resource_name_value", ) # Make the request page_result = client.query_grantable_roles(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.QueryGrantableRolesRequest, dict]) – The request object. The grantable role query request.
full_resource_name (str) –
Required. The full resource name to query from the list of grantable roles.
The name follows the Google Cloud Platform resource format. For example, a Cloud Platform project with id
my-project
will be named//cloudresourcemanager.googleapis.com/projects/my-project
.This corresponds to the
full_resource_name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The grantable role query response.
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesPager
- query_testable_permissions(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsPager [source]¶
Lists every permission that you can test on a resource. A permission is testable if you can check whether a principal has that permission on the resource.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_query_testable_permissions(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.QueryTestablePermissionsRequest( ) # Make the request page_result = client.query_testable_permissions(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.QueryTestablePermissionsRequest, dict]) – The request object. A request to get permissions which can be tested on a resource.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
The response containing permissions which can be tested on a resource. Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsPager
- static service_account_path(project: str, service_account: str) str [source]¶
Returns a fully-qualified service_account string.
- set_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Sets the IAM policy that is attached to a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Use this method to grant or revoke access to the service account. For example, you could grant a principal the ability to impersonate the service account.
This method does not enable the service account to access other resources. To grant roles to a service account on a resource, follow these steps:
Call the resource’s
getIamPolicy
method to get its current IAM policy.Edit the policy so that it binds the service account to an IAM role for the resource.
Call the resource’s
setIamPolicy
method to update its IAM policy.
For detailed instructions, see Manage access to project, folders, and organizations or Manage access to other resources.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request response = client.set_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]) – The request object. Request message for
SetIamPolicy
method.resource (str) –
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- sign_blob(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.SignBlobRequest, dict]] = None, *, name: Optional[str] = None, bytes_to_sign: Optional[bytes] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.SignBlobResponse [source]¶
Note: This method is deprecated. Use the
`signBlob
<https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signBlob>`__ method in the IAM Service Account Credentials API instead. If you currently use this method, see the migration guide for instructions.Signs a blob using the system-managed private key for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_sign_blob(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.SignBlobRequest( name="name_value", bytes_to_sign=b'bytes_to_sign_blob', ) # Make the request response = client.sign_blob(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.SignBlobRequest, dict]) –
The request object. Deprecated. Migrate to Service Account Credentials API.
The service account sign blob request.
name (str) –
Required. Deprecated. Migrate to Service Account Credentials API.
The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.bytes_to_sign (bytes) –
Required. Deprecated. Migrate to Service Account Credentials API.
The bytes to sign.
This corresponds to the
bytes_to_sign
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Deprecated. [Migrate to Service Account Credentials
API](https://cloud.google.com/iam/help/credentials/migrate-api).
The service account sign blob response.
- Return type
- sign_jwt(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.SignJwtRequest, dict]] = None, *, name: Optional[str] = None, payload: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.SignJwtResponse [source]¶
Note: This method is deprecated. Use the
`signJwt
<https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signJwt>`__ method in the IAM Service Account Credentials API instead. If you currently use this method, see the migration guide for instructions.Signs a JSON Web Token (JWT) using the system-managed private key for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_sign_jwt(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.SignJwtRequest( name="name_value", payload="payload_value", ) # Make the request response = client.sign_jwt(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.SignJwtRequest, dict]) –
The request object. Deprecated. Migrate to Service Account Credentials API.
The service account sign JWT request.
name (str) –
Required. Deprecated. Migrate to Service Account Credentials API.
The resource name of the service account in the following format:
projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}
. Using-
as a wildcard for thePROJECT_ID
will infer the project from the account. TheACCOUNT
value can be theemail
address or theunique_id
of the service account.This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.payload (str) –
Required. Deprecated. Migrate to Service Account Credentials API.
The JWT payload to sign. Must be a serialized JSON object that contains a JWT Claims Set. For example:
{"sub": "user@example.com", "iat": 313435}
If the JWT Claims Set contains an expiration time (
exp
) claim, it must be an integer timestamp that is not in the past and no more than 12 hours in the future.If the JWT Claims Set does not contain an expiration time (
exp
) claim, this claim is added automatically, with a timestamp that is 1 hour in the future.This corresponds to the
payload
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Deprecated. [Migrate to Service Account Credentials
API](https://cloud.google.com/iam/help/credentials/migrate-api).
The service account sign JWT response.
- Return type
- test_iam_permissions(request: Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, resource: Optional[str] = None, permissions: Optional[MutableSequence[str]] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse [source]¶
Tests whether the caller has the specified permissions on a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value1', 'permissions_value2'], ) # Make the request response = client.test_iam_permissions(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]) – The request object. Request message for
TestIamPermissions
method.resource (str) –
REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.permissions (MutableSequence[str]) –
The set of permissions to check for the
resource
. Permissions with wildcards (such as ‘*’ or ‘storage.*’) are not allowed. For more information see IAM Overview.This corresponds to the
permissions
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for TestIamPermissions method.
- Return type
google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse
- property transport: google.cloud.iam_admin_v1.services.iam.transports.base.IAMTransport¶
Returns the transport used by the client instance.
- Returns
- The transport used by the client
instance.
- Return type
IAMTransport
- undelete_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UndeleteRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Undeletes a custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_undelete_role(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.UndeleteRoleRequest( ) # Make the request response = client.undelete_role(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.UndeleteRoleRequest, dict]) – The request object. The request to undelete an existing role.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- undelete_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UndeleteServiceAccountRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.UndeleteServiceAccountResponse [source]¶
Restores a deleted [ServiceAccount][google.iam.admin.v1.ServiceAccount].
Important: It is not always possible to restore a deleted service account. Use this method only as a last resort.
After you delete a service account, IAM permanently removes the service account 30 days later. There is no way to restore a deleted service account that has been permanently removed.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_undelete_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.UndeleteServiceAccountRequest( ) # Make the request response = client.undelete_service_account(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.UndeleteServiceAccountRequest, dict]) – The request object. The service account undelete request.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Return type
google.cloud.iam_admin_v1.types.UndeleteServiceAccountResponse
- property universe_domain: str¶
Return the universe domain used by the client instance.
- Returns
The universe domain used by the client instance.
- Return type
- update_role(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UpdateRoleRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.Role [source]¶
Updates the definition of a custom [Role][google.iam.admin.v1.Role].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_update_role(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.UpdateRoleRequest( ) # Make the request response = client.update_role(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.UpdateRoleRequest, dict]) – The request object. The request to update a role.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A role in the Identity and Access Management API.
- Return type
- update_service_account(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.ServiceAccount, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccount [source]¶
Note: We are in the process of deprecating this method. Use [PatchServiceAccount][google.iam.admin.v1.IAM.PatchServiceAccount] instead.
Updates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
You can update only the
display_name
field.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_update_service_account(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.ServiceAccount( ) # Make the request response = client.update_service_account(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.ServiceAccount, dict]) –
The request object. An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the overview of service accounts.
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
An IAM service account.
A service account is an account for an application or a virtual machine (VM) instance, not a person. You can use a service account to call Google APIs. To learn more, read the [overview of service accounts](https://cloud.google.com/iam/help/service-accounts/overview).
When you create a service account, you specify the project ID that owns the service account, as well as a name that must be unique within the project. IAM uses these values to create an email address that identifies the service account.
- Return type
- upload_service_account_key(request: Optional[Union[google.cloud.iam_admin_v1.types.iam.UploadServiceAccountKeyRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.iam_admin_v1.types.iam.ServiceAccountKey [source]¶
Uploads the public key portion of a key pair that you manage, and associates the public key with a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
After you upload the public key, you can use the private key from the key pair as a service account key.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import iam_admin_v1 def sample_upload_service_account_key(): # Create a client client = iam_admin_v1.IAMClient() # Initialize request argument(s) request = iam_admin_v1.UploadServiceAccountKeyRequest( ) # Make the request response = client.upload_service_account_key(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.iam_admin_v1.types.UploadServiceAccountKeyRequest, dict]) – The request object. The service account key upload request.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Represents a service account key.
A service account has two sets of key-pairs: user-managed, and system-managed.
User-managed key-pairs can be created and deleted by users. Users are responsible for rotating these keys periodically to ensure security of their service accounts. Users retain the private key of these key-pairs, and Google retains ONLY the public key.
System-managed keys are automatically rotated by Google, and are used for signing for a maximum of two weeks. The rotation process is probabilistic, and usage of the new key will gradually ramp up and down over the key’s lifetime.
If you cache the public key set for a service account, we recommend that you update the cache every 15 minutes. User-managed keys can be added and removed at any time, so it is important to update the cache frequently. For Google-managed keys, Google will publish a key at least 6 hours before it is first used for signing and will keep publishing it for at least 6 hours after it was last used for signing.
Public keys for all service accounts are also published at the OAuth2 Service Account API.
- Return type
- class google.cloud.iam_admin_v1.services.iam.pagers.ListRolesAsyncPager(method: Callable[[...], Awaitable[google.cloud.iam_admin_v1.types.iam.ListRolesResponse]], request: google.cloud.iam_admin_v1.types.iam.ListRolesRequest, response: google.cloud.iam_admin_v1.types.iam.ListRolesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_roles
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.ListRolesResponse
object, and provides an__aiter__
method to iterate through itsroles
field.If there are more pages, the
__aiter__
method will make additionalListRoles
requests and continue to iterate through theroles
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.ListRolesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.ListRolesRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.ListRolesResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.ListRolesPager(method: Callable[[...], google.cloud.iam_admin_v1.types.iam.ListRolesResponse], request: google.cloud.iam_admin_v1.types.iam.ListRolesRequest, response: google.cloud.iam_admin_v1.types.iam.ListRolesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_roles
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.ListRolesResponse
object, and provides an__iter__
method to iterate through itsroles
field.If there are more pages, the
__iter__
method will make additionalListRoles
requests and continue to iterate through theroles
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.ListRolesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.ListRolesRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.ListRolesResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsAsyncPager(method: Callable[[...], Awaitable[google.cloud.iam_admin_v1.types.iam.ListServiceAccountsResponse]], request: google.cloud.iam_admin_v1.types.iam.ListServiceAccountsRequest, response: google.cloud.iam_admin_v1.types.iam.ListServiceAccountsResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_service_accounts
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.ListServiceAccountsResponse
object, and provides an__aiter__
method to iterate through itsaccounts
field.If there are more pages, the
__aiter__
method will make additionalListServiceAccounts
requests and continue to iterate through theaccounts
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.ListServiceAccountsResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.ListServiceAccountsRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.ListServiceAccountsResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.ListServiceAccountsPager(method: Callable[[...], google.cloud.iam_admin_v1.types.iam.ListServiceAccountsResponse], request: google.cloud.iam_admin_v1.types.iam.ListServiceAccountsRequest, response: google.cloud.iam_admin_v1.types.iam.ListServiceAccountsResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_service_accounts
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.ListServiceAccountsResponse
object, and provides an__iter__
method to iterate through itsaccounts
field.If there are more pages, the
__iter__
method will make additionalListServiceAccounts
requests and continue to iterate through theaccounts
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.ListServiceAccountsResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.ListServiceAccountsRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.ListServiceAccountsResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesAsyncPager(method: Callable[[...], Awaitable[google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesResponse]], request: google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesRequest, response: google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
query_grantable_roles
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse
object, and provides an__aiter__
method to iterate through itsroles
field.If there are more pages, the
__aiter__
method will make additionalQueryGrantableRoles
requests and continue to iterate through theroles
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.QueryGrantableRolesRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.QueryGrantableRolesPager(method: Callable[[...], google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesResponse], request: google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesRequest, response: google.cloud.iam_admin_v1.types.iam.QueryGrantableRolesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
query_grantable_roles
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse
object, and provides an__iter__
method to iterate through itsroles
field.If there are more pages, the
__iter__
method will make additionalQueryGrantableRoles
requests and continue to iterate through theroles
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.QueryGrantableRolesRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.QueryGrantableRolesResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsAsyncPager(method: Callable[[...], Awaitable[google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsResponse]], request: google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsRequest, response: google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
query_testable_permissions
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse
object, and provides an__aiter__
method to iterate through itspermissions
field.If there are more pages, the
__aiter__
method will make additionalQueryTestablePermissions
requests and continue to iterate through thepermissions
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.QueryTestablePermissionsRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.iam_admin_v1.services.iam.pagers.QueryTestablePermissionsPager(method: Callable[[...], google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsResponse], request: google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsRequest, response: google.cloud.iam_admin_v1.types.iam.QueryTestablePermissionsResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
query_testable_permissions
requests.This class thinly wraps an initial
google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse
object, and provides an__iter__
method to iterate through itspermissions
field.If there are more pages, the
__iter__
method will make additionalQueryTestablePermissions
requests and continue to iterate through thepermissions
field on the corresponding responses.All the usual
google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.iam_admin_v1.types.QueryTestablePermissionsRequest) – The initial request object.
response (google.cloud.iam_admin_v1.types.QueryTestablePermissionsResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.