3.16.0 (latest) 3.15.0 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.1 3.2.2 3.1.1 3.0.0 2.24.2 2.23.0 2.22.0 2.21.4 2.20.0 2.19.2 2.18.0 2.17.0 2.16.1 2.15.0 2.14.1 2.13.0 2.12.3 2.11.2 2.10.1 2.9.0 2.8.0 2.7.0 2.6.1 2.5.0 2.4.3 2.3.0 2.2.0 2.1.0 2.0.1 1.4.2 1.3.0 1.2.1 1.1.0

    KeyManagementServiceClient(
        *,
        credentials: typing.Optional[google.auth.credentials.Credentials] = None,
        transport: typing.Optional[
            typing.Union[
                str,
                google.cloud.kms_v1.services.key_management_service.transports.base.KeyManagementServiceTransport,
                typing.Callable[
                    [...],
                    google.cloud.kms_v1.services.key_management_service.transports.base.KeyManagementServiceTransport,
                ],
            ]
        ] = 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
    )

Google Cloud Key Management Service

Manages cryptographic keys and operations using those keys.
Implements a REST model with the following objects:

- KeyRing
- CryptoKey
- CryptoKeyVersion
- ImportJob

If you are using manual gRPC libraries, see `Using gRPC with Cloud
KMS <https://cloud.google.com/kms/docs/grpc>`__.

## Properties

### api_endpoint

Return the API endpoint used by the client instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `str` | The API endpoint used by the client instance. |

### transport

Returns the transport used by the client instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `KeyManagementServiceTransport` | The transport used by the client instance. |

### universe_domain

Return the universe domain used by the client instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `str` | The universe domain used by the client instance. |

## Methods

### KeyManagementServiceClient

    KeyManagementServiceClient(
        *,
        credentials: typing.Optional[google.auth.credentials.Credentials] = None,
        transport: typing.Optional[
            typing.Union[
                str,
                google.cloud.kms_v1.services.key_management_service.transports.base.KeyManagementServiceTransport,
                typing.Callable[
                    [...],
                    google.cloud.kms_v1.services.key_management_service.transports.base.KeyManagementServiceTransport,
                ],
            ]
        ] = 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
    )

Instantiates the key management service client.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `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,KeyManagementServiceTransport,Callable[..., KeyManagementServiceTransport]]]` 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 KeyManagementServiceTransport 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 when `transport` is not explicitly provided. Only if this property is not set and `transport` 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 the `api_endpoint` property still takes precedence; and `universe_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. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `google.auth.exceptions.MutualTLSChannelError` | If mutual TLS transport creation failed for any reason. |

### __exit__

    __exit__(type, value, traceback)

Releases underlying transport's resources.

> [!WARNING]
> **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!

### asymmetric_decrypt

    asymmetric_decrypt(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.AsymmetricDecryptRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        ciphertext: typing.Optional[bytes] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.AsymmetricDecryptResponse

Decrypts data that was encrypted with a public key retrieved
from
xref_GetPublicKey
corresponding to a
xref_CryptoKeyVersion with
xref_CryptoKey.purpose
ASYMMETRIC_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_asymmetric_decrypt():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricDecryptRequest.html(
            name="name_value",
            ciphertext=b'ciphertext_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_asymmetric_decrypt(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricDecryptRequest, dict]` The request object. Request message for KeyManagementService.AsymmetricDecrypt. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to use for decryption. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `ciphertext` | `bytes` Required. The data encrypted with the named CryptoKeyVersion's public key using OAEP. This corresponds to the `ciphertext` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricDecryptResponse` | Response message for KeyManagementService.AsymmetricDecrypt. |

### asymmetric_sign

    asymmetric_sign(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.AsymmetricSignRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        digest: typing.Optional[google.cloud.kms_v1.types.service.Digest] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.AsymmetricSignResponse

Signs data using a
xref_CryptoKeyVersion with
xref_CryptoKey.purpose
ASYMMETRIC_SIGN, producing a signature that can be verified with
the public key retrieved from
xref_GetPublicKey.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_asymmetric_sign():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricSignRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_asymmetric_sign(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricSignRequest, dict]` The request object. Request message for KeyManagementService.AsymmetricSign. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to use for signing. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `digest` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.Digest` Optional. The digest of the data to sign. The digest must be produced with the same digest algorithm as specified by the key version's algorithm. This field may not be supplied if AsymmetricSignRequest.data is supplied. This corresponds to the `digest` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.AsymmetricSignResponse` | Response message for KeyManagementService.AsymmetricSign. |

### common_billing_account_path

    common_billing_account_path(billing_account: str) -> str

Returns a fully-qualified billing_account string.

### common_folder_path

    common_folder_path(folder: str) -> str

Returns a fully-qualified folder string.

### common_location_path

    common_location_path(project: str, location: str) -> str

Returns a fully-qualified location string.

### common_organization_path

    common_organization_path(organization: str) -> str

Returns a fully-qualified organization string.

### common_project_path

    common_project_path(project: str) -> str

Returns a fully-qualified project string.

### create_crypto_key

    create_crypto_key(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.CreateCryptoKeyRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        crypto_key_id: typing.Optional[str] = None,
        crypto_key: typing.Optional[google.cloud.kms_v1.types.resources.CryptoKey] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKey

Create a new xref_CryptoKey within a
xref_KeyRing.

xref_CryptoKey.purpose and
xref_CryptoKey.version_template.algorithm
are required.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_create_crypto_key():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateCryptoKeyRequest.html(
            parent="parent_value",
            crypto_key_id="crypto_key_id_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_create_crypto_key(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateCryptoKeyRequest, dict]` The request object. Request message for KeyManagementService.CreateCryptoKey. |
| `parent` | `str` Required. The name of the KeyRing associated with the CryptoKeys. This corresponds to the `parent` field on the `request` instance; if `request` is provided, this should not be set. |
| `crypto_key_id` | `str` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` This corresponds to the `crypto_key_id` field on the `request` instance; if `request` is provided, this should not be set. |
| `crypto_key` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` Required. A CryptoKey with initial field values. This corresponds to the `crypto_key` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` | A CryptoKey represents a logical key that can be used for cryptographic operations. A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations. |

### create_crypto_key_version

    create_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.CreateCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        crypto_key_version: typing.Optional[
            google.cloud.kms_v1.types.resources.CryptoKeyVersion
        ] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Create a new
xref_CryptoKeyVersion in a
xref_CryptoKey.

The server will assign the next sequential id. If unset,
xref_state will be set
to
xref_ENABLED.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_create_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateCryptoKeyVersionRequest.html(
            parent="parent_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_create_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.CreateCryptoKeyVersion. |
| `parent` | `str` Required. The name of the CryptoKey associated with the CryptoKeyVersions. This corresponds to the `parent` field on the `request` instance; if `request` is provided, this should not be set. |
| `crypto_key_version` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` Required. A CryptoKeyVersion with initial field values. This corresponds to the `crypto_key_version` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### create_import_job

    create_import_job(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.CreateImportJobRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        import_job_id: typing.Optional[str] = None,
        import_job: typing.Optional[google.cloud.kms_v1.types.resources.ImportJob] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.ImportJob

Create a new xref_ImportJob within a
xref_KeyRing.

xref_ImportJob.import_method
is required.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_create_import_job():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        import_job = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportJob.html()
        import_job.import_method = "HPKE_KEM_XWING_HKDF_SHA256_AES_256_GCM"
        import_job.protection_level = "HSM_SINGLE_TENANT"

        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateImportJobRequest.html(
            parent="parent_value",
            import_job_id="import_job_id_value",
            import_job=import_job,
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_create_import_job(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateImportJobRequest, dict]` The request object. Request message for KeyManagementService.CreateImportJob. |
| `parent` | `str` Required. The name of the KeyRing associated with the ImportJobs. This corresponds to the `parent` field on the `request` instance; if `request` is provided, this should not be set. |
| `import_job_id` | `str` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` This corresponds to the `import_job_id` field on the `request` instance; if `request` is provided, this should not be set. |
| `import_job` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportJob` Required. An ImportJob with initial field values. This corresponds to the `import_job` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportJob` | An ImportJob can be used to create CryptoKeys and CryptoKeyVersions using pre-existing key material, generated outside of Cloud KMS. When an ImportJob is created, Cloud KMS will generate a "wrapping key", which is a public/private key pair. You use the wrapping key to encrypt (also known as wrap) the pre-existing key material to protect it during the import process. The nature of the wrapping key depends on the choice of import_method. When the wrapping key generation is complete, the state will be set to ACTIVE and the public_key can be fetched. The fetched public key can then be used to wrap your pre-existing key material. Once the key material is wrapped, it can be imported into a new CryptoKeyVersion in an existing CryptoKey by calling ImportCryptoKeyVersion. Multiple CryptoKeyVersions can be imported with a single ImportJob. Cloud KMS uses the private key portion of the wrapping key to unwrap the key material. Only Cloud KMS has access to the private key. An ImportJob expires 3 days after it is created. Once expired, Cloud KMS will no longer be able to import or unwrap any key material that was wrapped with the ImportJob's public key. For more information, see \[Importing a key\](https://cloud.google.com/kms/docs/importing-a-key). |

### create_key_ring

    create_key_ring(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.CreateKeyRingRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        key_ring_id: typing.Optional[str] = None,
        key_ring: typing.Optional[google.cloud.kms_v1.types.resources.KeyRing] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.KeyRing

Create a new xref_KeyRing in a given
Project and Location.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_create_key_ring():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateKeyRingRequest.html(
            parent="parent_value",
            key_ring_id="key_ring_id_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_create_key_ring(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CreateKeyRingRequest, dict]` The request object. Request message for KeyManagementService.CreateKeyRing. |
| `parent` | `str` Required. The resource name of the location associated with the KeyRings, in the format `projects//locations/`. This corresponds to the `parent` field on the `request` instance; if `request` is provided, this should not be set. |
| `key_ring_id` | `str` Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}` This corresponds to the `key_ring_id` field on the `request` instance; if `request` is provided, this should not be set. |
| `key_ring` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.KeyRing` Required. A KeyRing with initial field values. This corresponds to the `key_ring` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.KeyRing` | A KeyRing is a toplevel logical grouping of CryptoKeys. |

### crypto_key_path

    crypto_key_path(project: str, location: str, key_ring: str, crypto_key: str) -> str

Returns a fully-qualified crypto_key string.

### crypto_key_version_path

    crypto_key_version_path(
        project: str, location: str, key_ring: str, crypto_key: str, crypto_key_version: str
    ) -> str

Returns a fully-qualified crypto_key_version string.

### decapsulate

    decapsulate(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.DecapsulateRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.DecapsulateResponse

Decapsulates data that was encapsulated with a public key
retrieved from
xref_GetPublicKey
corresponding to a
xref_CryptoKeyVersion with
xref_CryptoKey.purpose
KEY_ENCAPSULATION.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_decapsulate():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecapsulateRequest.html(
            name="name_value",
            ciphertext=b'ciphertext_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_decapsulate(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecapsulateRequest, dict]` The request object. Request message for KeyManagementService.Decapsulate. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecapsulateResponse` | Response message for KeyManagementService.Decapsulate. |

### decrypt

    decrypt(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.DecryptRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        ciphertext: typing.Optional[bytes] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.DecryptResponse

Decrypts data that was protected by
xref_Encrypt. The
xref_CryptoKey.purpose must
be
xref_ENCRYPT_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_decrypt():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecryptRequest.html(
            name="name_value",
            ciphertext=b'ciphertext_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_decrypt(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecryptRequest, dict]` The request object. Request message for KeyManagementService.Decrypt. |
| `name` | `str` Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `ciphertext` | `bytes` Required. The encrypted data originally returned in EncryptResponse.ciphertext. This corresponds to the `ciphertext` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DecryptResponse` | Response message for KeyManagementService.Decrypt. |

### delete_crypto_key

    delete_crypto_key(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.DeleteCryptoKeyRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.api_core.operation.Operation

Permanently deletes the given
xref_CryptoKey. All child
xref_CryptoKeyVersions must
have been previously deleted using
xref_KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently
deleted upon calling this method. This action cannot be undone.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_delete_crypto_key():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DeleteCryptoKeyRequest.html(
            name="name_value",
        )

        # Make the request
        operation = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_delete_crypto_key(request=request)

        print("Waiting for operation to complete...")

        response = operation.result()

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DeleteCryptoKeyRequest, dict]` The request object. Request message for KeyManagementService.DeleteCryptoKey. |
| `name` | `str` Required. The name of the CryptoKey to delete. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `google.api_core.operation.Operation` | An object representing a long-running operation. The result type for the operation will be `google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } |

### delete_crypto_key_version

    delete_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.DeleteCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.api_core.operation.Operation

Permanently deletes the given
xref_CryptoKeyVersion. Only
possible if the version has not been previously imported and if
its xref_state is one
of `DESTROYED][CryptoKeyVersionState.DESTROYED]`,
`IMPORT_FAILED][CryptoKeyVersionState.IMPORT_FAILED]`, or
`GENERATION_FAILED][CryptoKeyVersionState.GENERATION_FAILED]`.
Successfully imported
xref_CryptoKeyVersions cannot
be deleted at this time. The specified version will be
immediately and permanently deleted upon calling this method.
This action cannot be undone.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_delete_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DeleteCryptoKeyVersionRequest.html(
            name="name_value",
        )

        # Make the request
        operation = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_delete_crypto_key_version(request=request)

        print("Waiting for operation to complete...")

        response = operation.result()

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DeleteCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.DeleteCryptoKeyVersion. |
| `name` | `str` Required. The name of the CryptoKeyVersion to delete. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `google.api_core.operation.Operation` | An object representing a long-running operation. The result type for the operation will be `google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } |

### destroy_crypto_key_version

    destroy_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.DestroyCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Schedule a
xref_CryptoKeyVersion for
destruction.

Upon calling this method,
xref_CryptoKeyVersion.state
will be set to
xref_DESTROY_SCHEDULED,
and
xref_destroy_time
will be set to the time
xref_destroy_scheduled_duration
in the future. At that time, the
xref_state will
automatically change to
xref_DESTROYED,
and the key material will be irrevocably destroyed.

Before the
xref_destroy_time
is reached,
xref_RestoreCryptoKeyVersion
may be called to reverse the process.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_destroy_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DestroyCryptoKeyVersionRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_destroy_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.DestroyCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.DestroyCryptoKeyVersion. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to destroy. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### encrypt

    encrypt(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.EncryptRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        plaintext: typing.Optional[bytes] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.EncryptResponse

Encrypts data, so that it can only be recovered by a call to
xref_Decrypt. The
xref_CryptoKey.purpose must
be
xref_ENCRYPT_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_encrypt():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.EncryptRequest.html(
            name="name_value",
            plaintext=b'plaintext_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_encrypt(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.EncryptRequest, dict]` The request object. Request message for KeyManagementService.Encrypt. |
| `name` | `str` Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its \[primary version\]\[google.cloud.kms.v1.CryptoKey.primary\]. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `plaintext` | `bytes` Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE, EXTERNAL, and EXTERNAL_VPC keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB. This corresponds to the `plaintext` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.EncryptResponse` | Response message for KeyManagementService.Encrypt. |

### export_trusted_key_wrapped_crypto_key_version

    export_trusted_key_wrapped_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.ExportTrustedKeyWrappedCryptoKeyVersionRequest,
                dict,
            ]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.ExportTrustedKeyWrappedCryptoKeyVersionResponse

Exports a
xref_CryptoKeyVersion with a
trusted key.

The xref_CryptoKeyVersion
must have trusted_wrapping_enabled set to true. The
xref_CryptoKeyVersion of the
\[wrapping_key\] must have the
xref_AES_WRAPPING
purpose. The \[wrapping_key\] must have the
xref_AES_256_KWP
algorithm.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_export_trusted_key_wrapped_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ExportTrustedKeyWrappedCryptoKeyVersionRequest.html(
            name="name_value",
            wrapping_key="wrapping_key_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_export_trusted_key_wrapped_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ExportTrustedKeyWrappedCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.ExportTrustedKeyWrappedCryptoKeyVersion. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ExportTrustedKeyWrappedCryptoKeyVersionResponse` | Response message for KeyManagementService.ExportTrustedKeyWrappedCryptoKeyVersion. |

### from_service_account_file

    from_service_account_file(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials
file.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `filename` | `str` The path to the service account private key json file. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `KeyManagementServiceClient` | The constructed client. |

### from_service_account_info

    from_service_account_info(info: dict, *args, **kwargs)

Creates an instance of this client using the provided credentials
info.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `info` | `dict` The service account private key info. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `KeyManagementServiceClient` | The constructed client. |

### from_service_account_json

    from_service_account_json(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials
file.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `filename` | `str` The path to the service account private key json file. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `KeyManagementServiceClient` | The constructed client. |

### generate_random_bytes

    generate_random_bytes(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GenerateRandomBytesRequest, dict]
        ] = None,
        *,
        location: typing.Optional[str] = None,
        length_bytes: typing.Optional[int] = None,
        protection_level: typing.Optional[
            google.cloud.kms_v1.types.resources.ProtectionLevel
        ] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.GenerateRandomBytesResponse

Generate random bytes using the Cloud KMS randomness
source in the provided location.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_generate_random_bytes():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GenerateRandomBytesRequest.html(
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_generate_random_bytes(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GenerateRandomBytesRequest, dict]` The request object. Request message for KeyManagementService.GenerateRandomBytes. |
| `location` | `str` The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1". This corresponds to the `location` field on the `request` instance; if `request` is provided, this should not be set. |
| `length_bytes` | `int` The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes. This corresponds to the `length_bytes` field on the `request` instance; if `request` is provided, this should not be set. |
| `protection_level` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ProtectionLevel` The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported. This corresponds to the `protection_level` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GenerateRandomBytesResponse` | Response message for KeyManagementService.GenerateRandomBytes. |

### get_crypto_key

    get_crypto_key(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetCryptoKeyRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKey

Returns metadata for a given
xref_CryptoKey, as well as its
xref_primary
xref_CryptoKeyVersion.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_crypto_key():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetCryptoKeyRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_crypto_key(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetCryptoKeyRequest, dict]` The request object. Request message for KeyManagementService.GetCryptoKey. |
| `name` | `str` Required. The name of the CryptoKey to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` | A CryptoKey represents a logical key that can be used for cryptographic operations. A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations. |

### get_crypto_key_version

    get_crypto_key_version(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetCryptoKeyVersionRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Returns metadata for a given
xref_CryptoKeyVersion.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetCryptoKeyVersionRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.GetCryptoKeyVersion. |
| `name` | `str` Required. The name of the CryptoKeyVersion to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### get_iam_policy

    get_iam_policy(
        request: typing.Optional[
            typing.Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.iam.v1.policy_pb2.Policy

Gets the IAM access control policy for a function.

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.iam_policy_pb2.GetIamPolicyRequest` `` The request object. Request message for `GetIamPolicy` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.policy_pb2.Policy` `` | Defines an Identity and Access Management (IAM) policy. It is used to specify access control policies for Cloud Platform resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members` to a single `role`. Members can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions (defined by IAM or configured by users). A `binding` can optionally specify a `condition`, which is a logic expression that further constrains the role binding based on attributes about the request and/or target resource. \*\*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')",="" }="" }="" \]="" }="" \*\*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')="" for="" a="" description="" of="" iam="" and="" its="" features,="" see="" the=""\>`IAM developer's guide `__. |

### get_import_job

    get_import_job(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetImportJobRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.ImportJob

Returns metadata for a given
xref_ImportJob.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_import_job():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetImportJobRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_import_job(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetImportJobRequest, dict]` The request object. Request message for KeyManagementService.GetImportJob. |
| `name` | `str` Required. The name of the ImportJob to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportJob` | An ImportJob can be used to create CryptoKeys and CryptoKeyVersions using pre-existing key material, generated outside of Cloud KMS. When an ImportJob is created, Cloud KMS will generate a "wrapping key", which is a public/private key pair. You use the wrapping key to encrypt (also known as wrap) the pre-existing key material to protect it during the import process. The nature of the wrapping key depends on the choice of import_method. When the wrapping key generation is complete, the state will be set to ACTIVE and the public_key can be fetched. The fetched public key can then be used to wrap your pre-existing key material. Once the key material is wrapped, it can be imported into a new CryptoKeyVersion in an existing CryptoKey by calling ImportCryptoKeyVersion. Multiple CryptoKeyVersions can be imported with a single ImportJob. Cloud KMS uses the private key portion of the wrapping key to unwrap the key material. Only Cloud KMS has access to the private key. An ImportJob expires 3 days after it is created. Once expired, Cloud KMS will no longer be able to import or unwrap any key material that was wrapped with the ImportJob's public key. For more information, see \[Importing a key\](https://cloud.google.com/kms/docs/importing-a-key). |

### get_key_ring

    get_key_ring(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetKeyRingRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.KeyRing

Returns metadata for a given
xref_KeyRing.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_key_ring():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetKeyRingRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_key_ring(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetKeyRingRequest, dict]` The request object. Request message for KeyManagementService.GetKeyRing. |
| `name` | `str` Required. The name of the KeyRing to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.KeyRing` | A KeyRing is a toplevel logical grouping of CryptoKeys. |

### get_location

    get_location(
        request: typing.Optional[
            typing.Union[google.cloud.location.locations_pb2.GetLocationRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.location.locations_pb2.Location

Gets information about a location.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.location_pb2.GetLocationRequest` `` The request object. Request message for `GetLocation` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.location_pb2.Location` `` | Location object. |

### get_mtls_endpoint_and_cert_source

    get_mtls_endpoint_and_cert_source(
        client_options: typing.Optional[
            google.api_core.client_options.ClientOptions
        ] = None,
    )

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>.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `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. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `google.auth.exceptions.MutualTLSChannelError` | If any errors happen. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Tuple[str, Callable[[], Tuple[bytes, bytes]]]` | returns the API endpoint and the client cert source to use. |

### get_operation

    get_operation(
        request: typing.Optional[
            typing.Union[google.longrunning.operations_pb2.GetOperationRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.longrunning.operations_pb2.Operation

Gets the latest state of a long-running operation.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.operations_pb2.GetOperationRequest` `` The request object. Request message for `GetOperation` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.operations_pb2.Operation` `` | An `Operation` object. |

### get_public_key

    get_public_key(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetPublicKeyRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.PublicKey

Returns the public key for the given
xref_CryptoKeyVersion. The
xref_CryptoKey.purpose must
be
xref_ASYMMETRIC_SIGN
or
xref_ASYMMETRIC_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_public_key():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetPublicKeyRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_public_key(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetPublicKeyRequest, dict]` The request object. Request message for KeyManagementService.GetPublicKey. |
| `name` | `str` Required. The name of the CryptoKeyVersion public key to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.PublicKey` | The public keys for a given CryptoKeyVersion. Obtained via GetPublicKey. |

### get_retired_resource

    get_retired_resource(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.GetRetiredResourceRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.RetiredResource

Retrieves a specific
xref_RetiredResource resource,
which represents the record of a deleted
xref_CryptoKey.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_get_retired_resource():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetRetiredResourceRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_get_retired_resource(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.GetRetiredResourceRequest, dict]` The request object. Request message for KeyManagementService.GetRetiredResource. |
| `name` | `str` Required. The name of the RetiredResource to get. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RetiredResource` | A RetiredResource resource represents the record of a deleted CryptoKey. Its purpose is to provide visibility into retained user data and to prevent reuse of these names for new CryptoKeys. |

### import_crypto_key_version

    import_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.ImportCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Import wrapped key material into a
xref_CryptoKeyVersion.

All requests must specify a
xref_CryptoKey. If a
xref_CryptoKeyVersion is
additionally specified in the request, key material will be
reimported into that version. Otherwise, a new version will be
created, and will be assigned the next sequential id within the
xref_CryptoKey.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_import_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportCryptoKeyVersionRequest.html(
            rsa_aes_wrapped_key=b'rsa_aes_wrapped_key_blob',
            parent="parent_value",
            algorithm="AES_256_KWP",
            import_job="import_job_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_import_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.ImportCryptoKeyVersion. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### import_job_path

    import_job_path(project: str, location: str, key_ring: str, import_job: str) -> str

Returns a fully-qualified import_job string.

### import_trusted_key_wrapped_crypto_key_version

    import_trusted_key_wrapped_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.ImportTrustedKeyWrappedCryptoKeyVersionRequest,
                dict,
            ]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Import wrapped key material into a
xref_CryptoKeyVersion with a
trusted key.

All requests must specify a
xref_CryptoKey. If a
xref_CryptoKeyVersion is
additionally specified in the request, key material will be
reimported into that version. Otherwise, a new version will be
created, and will be assigned the next sequential id within the
xref_CryptoKey.

The xref_CryptoKeyVersion
will have trusted_wrapping_enabled set to true.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_import_trusted_key_wrapped_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportTrustedKeyWrappedCryptoKeyVersionRequest.html(
            parent="parent_value",
            importing_key="importing_key_value",
            wrapped_key=b'wrapped_key_blob',
            algorithm="AES_256_KWP",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_import_trusted_key_wrapped_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ImportTrustedKeyWrappedCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.ImportTrustedKeyWrappedCryptoKeyVersion. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### key_ring_path

    key_ring_path(project: str, location: str, key_ring: str) -> str

Returns a fully-qualified key_ring string.

### list_crypto_key_versions

    list_crypto_key_versions(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.ListCryptoKeyVersionsRequest, dict
            ]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> (
        google.cloud.kms_v1.services.key_management_service.pagers.ListCryptoKeyVersionsPager
    )

Lists xref_CryptoKeyVersions.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_list_crypto_key_versions():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListCryptoKeyVersionsRequest.html(
            parent="parent_value",
        )

        # Make the request
        page_result = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_list_crypto_key_versions(request=request)

        # Handle the response
        for response in page_result:
            print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListCryptoKeyVersionsRequest, dict]` The request object. Request message for KeyManagementService.ListCryptoKeyVersions. |
| `parent` | `str` Required. The resource name of the CryptoKey to list, in the format `projects//locations//keyRings//cryptoKeys/`. This corresponds to the `parent` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.pagers.ListCryptoKeyVersionsPager` | Response message for KeyManagementService.ListCryptoKeyVersions. Iterating over this object will yield results and resolve additional pages automatically. |

### list_crypto_keys

    list_crypto_keys(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.ListCryptoKeysRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.services.key_management_service.pagers.ListCryptoKeysPager

Lists xref_CryptoKeys.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_list_crypto_keys():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.ListCryptoKeysRequest(
            parent="parent_value",
        )

        # Make the request
        page_result = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_list_crypto_keys(request=request)

        # Handle the response
        for response in page_result:
            print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListCryptoKeysRequest, dict]` The request object. Request message for KeyManagementService.ListCryptoKeys. |
| `parent` | `str` Required. The resource name of the KeyRing to list, in the format `projects//locations//keyRings/*`. This corresponds to the `parent` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.pagers.ListCryptoKeysPager` | Response message for KeyManagementService.ListCryptoKeys. Iterating over this object will yield results and resolve additional pages automatically. |

### list_import_jobs

    list_import_jobs(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.ListImportJobsRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.services.key_management_service.pagers.ListImportJobsPager

Lists xref_ImportJobs.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_list_import_jobs():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListImportJobsRequest.html(
            parent="parent_value",
        )

        # Make the request
        page_result = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_list_import_jobs(request=request)

        # Handle the response
        for response in page_result:
            print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListImportJobsRequest, dict]` The request object. Request message for KeyManagementService.ListImportJobs. |
| `parent` | `str` Required. The resource name of the KeyRing to list, in the format `projects//locations//keyRings/*`. This corresponds to the `parent` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.pagers.ListImportJobsPager` | Response message for KeyManagementService.ListImportJobs. Iterating over this object will yield results and resolve additional pages automatically. |

### list_key_rings

    list_key_rings(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.ListKeyRingsRequest, dict]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.services.key_management_service.pagers.ListKeyRingsPager

Lists xref_KeyRings.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_list_key_rings():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListKeyRingsRequest.html(
            parent="parent_value",
        )

        # Make the request
        page_result = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_list_key_rings(request=request)

        # Handle the response
        for response in page_result:
            print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListKeyRingsRequest, dict]` The request object. Request message for KeyManagementService.ListKeyRings. |
| `parent` | `str` Required. The resource name of the location associated with the KeyRings, in the format `projects//locations/`. This corresponds to the `parent` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.pagers.ListKeyRingsPager` | Response message for KeyManagementService.ListKeyRings. Iterating over this object will yield results and resolve additional pages automatically. |

### list_locations

    list_locations(
        request: typing.Optional[
            typing.Union[google.cloud.location.locations_pb2.ListLocationsRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.location.locations_pb2.ListLocationsResponse

Lists information about the supported locations for this service.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.location_pb2.ListLocationsRequest` `` The request object. Request message for `ListLocations` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.location_pb2.ListLocationsResponse` `` | Response message for `ListLocations` method. |

### list_retired_resources

    list_retired_resources(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.ListRetiredResourcesRequest, dict
            ]
        ] = None,
        *,
        parent: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> (
        google.cloud.kms_v1.services.key_management_service.pagers.ListRetiredResourcesPager
    )

Lists the
xref_RetiredResources which
are the records of deleted
xref_CryptoKeys. RetiredResources
prevent the reuse of these resource names after deletion.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_list_retired_resources():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListRetiredResourcesRequest.html(
            parent="parent_value",
        )

        # Make the request
        page_result = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_list_retired_resources(request=request)

        # Handle the response
        for response in page_result:
            print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.ListRetiredResourcesRequest, dict]` The request object. Request message for KeyManagementService.ListRetiredResources. |
| `parent` | `str` Required. The project-specific location holding the RetiredResources, in the format `projects//locations/`. This corresponds to the `parent` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.pagers.ListRetiredResourcesPager` | Response message for KeyManagementService.ListRetiredResources. Iterating over this object will yield results and resolve additional pages automatically. |

### mac_sign

    mac_sign(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.MacSignRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        data: typing.Optional[bytes] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.MacSignResponse

Signs data using a
xref_CryptoKeyVersion with
xref_CryptoKey.purpose MAC,
producing a tag that can be verified by another source with the
same 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_mac_sign():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacSignRequest.html(
            name="name_value",
            data=b'data_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_mac_sign(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacSignRequest, dict]` The request object. Request message for KeyManagementService.MacSign. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to use for signing. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `data` | `bytes` Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm. This corresponds to the `data` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacSignResponse` | Response message for KeyManagementService.MacSign. |

### mac_verify

    mac_verify(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.MacVerifyRequest, dict]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        data: typing.Optional[bytes] = None,
        mac: typing.Optional[bytes] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.MacVerifyResponse

Verifies MAC tag using a
xref_CryptoKeyVersion with
xref_CryptoKey.purpose MAC,
and returns a response that indicates whether or not the
verification was successful.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_mac_verify():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacVerifyRequest.html(
            name="name_value",
            data=b'data_blob',
            mac=b'mac_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_mac_verify(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacVerifyRequest, dict]` The request object. Request message for KeyManagementService.MacVerify. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to use for verification. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `data` | `bytes` Required. The data used previously as a MacSignRequest.data to generate the MAC tag. This corresponds to the `data` field on the `request` instance; if `request` is provided, this should not be set. |
| `mac` | `bytes` Required. The signature to verify. This corresponds to the `mac` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.MacVerifyResponse` | Response message for KeyManagementService.MacVerify. |

### parse_common_billing_account_path

    parse_common_billing_account_path(path: str) -> typing.Dict[str, str]

Parse a billing_account path into its component segments.

### parse_common_folder_path

    parse_common_folder_path(path: str) -> typing.Dict[str, str]

Parse a folder path into its component segments.

### parse_common_location_path

    parse_common_location_path(path: str) -> typing.Dict[str, str]

Parse a location path into its component segments.

### parse_common_organization_path

    parse_common_organization_path(path: str) -> typing.Dict[str, str]

Parse a organization path into its component segments.

### parse_common_project_path

    parse_common_project_path(path: str) -> typing.Dict[str, str]

Parse a project path into its component segments.

### parse_crypto_key_path

    parse_crypto_key_path(path: str) -> typing.Dict[str, str]

Parses a crypto_key path into its component segments.

### parse_crypto_key_version_path

    parse_crypto_key_version_path(path: str) -> typing.Dict[str, str]

Parses a crypto_key_version path into its component segments.

### parse_import_job_path

    parse_import_job_path(path: str) -> typing.Dict[str, str]

Parses a import_job path into its component segments.

### parse_key_ring_path

    parse_key_ring_path(path: str) -> typing.Dict[str, str]

Parses a key_ring path into its component segments.

### parse_public_key_path

    parse_public_key_path(path: str) -> typing.Dict[str, str]

Parses a public_key path into its component segments.

### parse_retired_resource_path

    parse_retired_resource_path(path: str) -> typing.Dict[str, str]

Parses a retired_resource path into its component segments.

### public_key_path

    public_key_path(
        project: str, location: str, key_ring: str, crypto_key: str, crypto_key_version: str
    ) -> str

Returns a fully-qualified public_key string.

### raw_decrypt

    raw_decrypt(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.RawDecryptRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.RawDecryptResponse

Decrypts data that was originally encrypted using a raw
cryptographic mechanism. The
xref_CryptoKey.purpose must
be
xref_RAW_ENCRYPT_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_raw_decrypt():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawDecryptRequest.html(
            name="name_value",
            ciphertext=b'ciphertext_blob',
            initialization_vector=b'initialization_vector_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_raw_decrypt(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawDecryptRequest, dict]` The request object. Request message for KeyManagementService.RawDecrypt. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawDecryptResponse` | Response message for KeyManagementService.RawDecrypt. |

### raw_encrypt

    raw_encrypt(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.RawEncryptRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.service.RawEncryptResponse

Encrypts data using portable cryptographic primitives. Most
users should choose
xref_Encrypt and
xref_Decrypt
rather than their raw counterparts. The
xref_CryptoKey.purpose must
be
xref_RAW_ENCRYPT_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_raw_encrypt():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawEncryptRequest.html(
            name="name_value",
            plaintext=b'plaintext_blob',
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_raw_encrypt(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawEncryptRequest, dict]` The request object. Request message for KeyManagementService.RawEncrypt. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RawEncryptResponse` | Response message for KeyManagementService.RawEncrypt. |

### restore_crypto_key_version

    restore_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.RestoreCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Restore a
xref_CryptoKeyVersion in the
xref_DESTROY_SCHEDULED
state.

Upon restoration of the CryptoKeyVersion,
xref_state will be set
to
xref_DISABLED,
and
xref_destroy_time
will be cleared.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_restore_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RestoreCryptoKeyVersionRequest.html(
            name="name_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_restore_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.RestoreCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.RestoreCryptoKeyVersion. |
| `name` | `str` Required. The resource name of the CryptoKeyVersion to restore. This corresponds to the `name` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |

### retired_resource_path

    retired_resource_path(project: str, location: str, retired_resource: str) -> str

Returns a fully-qualified retired_resource string.

### set_iam_policy

    set_iam_policy(
        request: typing.Optional[
            typing.Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.iam.v1.policy_pb2.Policy

Sets the IAM access control policy on the specified function.

Replaces any existing policy.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.iam_policy_pb2.SetIamPolicyRequest` `` The request object. Request message for `SetIamPolicy` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.policy_pb2.Policy` `` | Defines an Identity and Access Management (IAM) policy. It is used to specify access control policies for Cloud Platform resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members` to a single `role`. Members can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions (defined by IAM or configured by users). A `binding` can optionally specify a `condition`, which is a logic expression that further constrains the role binding based on attributes about the request and/or target resource. \*\*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')",="" }="" }="" \]="" }="" \*\*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')="" for="" a="" description="" of="" iam="" and="" its="" features,="" see="" the=""\>`IAM developer's guide `__. |

### test_iam_permissions

    test_iam_permissions(
        request: typing.Optional[
            typing.Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]
        ] = None,
        *,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse

Tests the specified IAM permissions against the IAM access control
policy for a function.

If the function does not exist, this will return an empty set
of permissions, not a NOT_FOUND error.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `` `.iam_policy_pb2.TestIamPermissionsRequest` `` The request object. Request message for `TestIamPermissions` method. |
| `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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.iam_policy_pb2.TestIamPermissionsResponse` `` | Response message for `TestIamPermissions` method. |

### update_crypto_key

    update_crypto_key(
        request: typing.Optional[
            typing.Union[google.cloud.kms_v1.types.service.UpdateCryptoKeyRequest, dict]
        ] = None,
        *,
        crypto_key: typing.Optional[google.cloud.kms_v1.types.resources.CryptoKey] = None,
        update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKey

Update a xref_CryptoKey.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_update_crypto_key():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyRequest.html(
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_update_crypto_key(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyRequest, dict]` The request object. Request message for KeyManagementService.UpdateCryptoKey. |
| `crypto_key` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` Required. CryptoKey with updated values. This corresponds to the `crypto_key` field on the `request` instance; if `request` is provided, this should not be set. |
| `update_mask` | `google.protobuf.field_mask_pb2.FieldMask` Required. List of fields to be updated in this request. This corresponds to the `update_mask` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` | A CryptoKey represents a logical key that can be used for cryptographic operations. A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations. |

### update_crypto_key_primary_version

    update_crypto_key_primary_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.UpdateCryptoKeyPrimaryVersionRequest, dict
            ]
        ] = None,
        *,
        name: typing.Optional[str] = None,
        crypto_key_version_id: typing.Optional[str] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKey

Update the version of a
xref_CryptoKey that will be used in
xref_Encrypt.

Returns an error if called on a key whose purpose is not
xref_ENCRYPT_DECRYPT.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_update_crypto_key_primary_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyPrimaryVersionRequest.html(
            name="name_value",
            crypto_key_version_id="crypto_key_version_id_value",
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_update_crypto_key_primary_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyPrimaryVersionRequest, dict]` The request object. Request message for KeyManagementService.UpdateCryptoKeyPrimaryVersion. |
| `name` | `str` Required. The resource name of the CryptoKey to update. This corresponds to the `name` field on the `request` instance; if `request` is provided, this should not be set. |
| `crypto_key_version_id` | `str` Required. The id of the child CryptoKeyVersion to use as primary. This corresponds to the `crypto_key_version_id` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKey` | A CryptoKey represents a logical key that can be used for cryptographic operations. A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations. |

### update_crypto_key_version

    update_crypto_key_version(
        request: typing.Optional[
            typing.Union[
                google.cloud.kms_v1.types.service.UpdateCryptoKeyVersionRequest, dict
            ]
        ] = None,
        *,
        crypto_key_version: typing.Optional[
            google.cloud.kms_v1.types.resources.CryptoKeyVersion
        ] = None,
        update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
        retry: typing.Optional[
            typing.Union[
                google.api_core.retry.retry_unary.Retry,
                google.api_core.gapic_v1.method._MethodDefault,
            ]
        ] = _MethodDefault._DEFAULT_VALUE,
        timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
        metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = ()
    ) -> google.cloud.kms_v1.types.resources.CryptoKeyVersion

Update a
xref_CryptoKeyVersion's
metadata.

xref_state may be
changed between
xref_ENABLED
and
xref_DISABLED
using this method. See
xref_DestroyCryptoKeyVersion
and
xref_RestoreCryptoKeyVersion
to move between other states.

    # 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 https://docs.cloud.google.com/python/docs/reference/cloudkms/latest

    def sample_update_crypto_key_version():
        # Create a client
        client = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html()

        # Initialize request argument(s)
        request = https://docs.cloud.google.com/python/docs/reference/cloudkms/latest.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyVersionRequest.html(
        )

        # Make the request
        response = client.https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.services.key_management_service.KeyManagementServiceClient.html#google_cloud_kms_v1_services_key_management_service_KeyManagementServiceClient_update_crypto_key_version(request=request)

        # Handle the response
        print(response)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Union[https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.UpdateCryptoKeyVersionRequest, dict]` The request object. Request message for KeyManagementService.UpdateCryptoKeyVersion. |
| `crypto_key_version` | `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` Required. CryptoKeyVersion with updated values. This corresponds to the `crypto_key_version` field on the `request` instance; if `request` is provided, this should not be set. |
| `update_mask` | `google.protobuf.field_mask_pb2.FieldMask` Required. List of fields to be updated in this request. This corresponds to the `update_mask` field on the `request` instance; if `request` 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, Union[str, bytes]]]` Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/cloudkms/latest/google.cloud.kms_v1.types.CryptoKeyVersion` | A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS. |