6f9eacfd1d5f6ebf961d134f538e7613c0b9fc25,kms/api-client/snippets.py,,disable_crypto_key_version,#Any#Any#Any#Any#Any#,132

Before Change


    KeyRing.

    // Creates an API client for the KMS API.
    kms_client = googleapiclient.discovery.build("cloudkms", "v1")

    // Construct the resource name of the CryptoKeyVersion.
    name = (
        "projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}/"
        "cryptoKeyVersions/{}"
        .format(
            project_id, location_id, key_ring_id, crypto_key_id, version_id))

    // Use the KMS API to disable the CryptoKeyVersion.
    crypto_keys = kms_client.projects().locations().keyRings().cryptoKeys()
    request = crypto_keys.cryptoKeyVersions().patch(
        name=name, body={"state": "DISABLED"}, updateMask="state")
    response = request.execute()

    print("CryptoKeyVersion {}\"s state has been set to {}.".format(
        name, response["state"]))
// [END kms_disable_cryptokey_version]

After Change


    KeyRing.

    // Creates an API client for the KMS API.
    client = kms_v1.KeyManagementServiceClient()

    // Construct the resource name of the CryptoKeyVersion.
    name = client.crypto_key_version_path(project_id, location_id, key_ring_id,
                                          crypto_key_id, version_id)

    // Use the KMS API to disable the CryptoKeyVersion.
    new_state = enums.CryptoKeyVersion.CryptoKeyVersionState.DISABLED
    version = {"name": name, "state": new_state}
    update_mask = {"paths": ["state"]}

    // Print results
    response = client.update_crypto_key_version(version, update_mask)
    print("CryptoKeyVersion {}\"s state has been set to {}.".format(
        name, response.state))
// [END kms_disable_cryptokey_version]

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 17

Instances


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 6f9eacfd1d5f6ebf961d134f538e7613c0b9fc25
Time: 2019-01-07
Author: d.sanche14@gmail.com
File Name: kms/api-client/snippets.py
Class Name:
Method Name: disable_crypto_key_version


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 6f9eacfd1d5f6ebf961d134f538e7613c0b9fc25
Time: 2019-01-07
Author: d.sanche14@gmail.com
File Name: kms/api-client/snippets.py
Class Name:
Method Name: enable_crypto_key_version


Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 6f9eacfd1d5f6ebf961d134f538e7613c0b9fc25
Time: 2019-01-07
Author: d.sanche14@gmail.com
File Name: kms/api-client/snippets.py
Class Name:
Method Name: create_crypto_key