6f9eacfd1d5f6ebf961d134f538e7613c0b9fc25,kms/api-client/snippets.py,,create_crypto_key,#Any#Any#Any#Any#,43

Before Change


    Creates a CryptoKey within a KeyRing in the given location.

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

    // The resource name of the KeyRing associated with the CryptoKey.
    parent = "projects/{}/locations/{}/keyRings/{}".format(
        project_id, location_id, key_ring_id)

    // Create a CryptoKey for the given KeyRing.
    request = kms_client.projects().locations().keyRings().cryptoKeys().create(
        parent=parent, body={"purpose": "ENCRYPT_DECRYPT"},
        cryptoKeyId=crypto_key_id)
    response = request.execute()

    print("Created CryptoKey {}.".format(response["name"]))
// [END kms_create_cryptokey]

After Change


    Creates a CryptoKey within a KeyRing in the given location.

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

    // The resource name of the KeyRing associated with the CryptoKey.
    parent = client.key_ring_path(project_id, location_id, key_ring_id)

    // Create the CryptoKey object template
    purpose = enums.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT
    crypto_key = {"purpose": purpose}

    // Create a CryptoKey for the given KeyRing.
    response = client.create_crypto_key(parent, crypto_key_id, crypto_key)

    print("Created CryptoKey {}.".format(response.name))
    return response
// [END kms_create_cryptokey]


// [START kms_encrypt]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 15

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: create_crypto_key


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: get_key_ring_policy


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_key_ring


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