Last active
May 1, 2024 21:58
-
-
Save henriquez/2f91fcc9a8417a8e76c1edf54e1d8002 to your computer and use it in GitHub Desktop.
Secret Manager create secret function examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create secret in secret manager: proposed generated sample | |
# All of these samples assume that detail about the arguments is provided on the same page below the sample. In the case of | |
# protobuf types - since they are not described in the SDK reference docs, we'd create new doc content and link to them | |
# describing how to convert from native types to protobuf types. | |
# Since the existing docs are not clear, take this as an example not nec. as what the API actually requires. | |
# EX 1: In this example we put the types as comments, see below for other options | |
response = client.create_secret( | |
request={ | |
"parent": parent, # REQUIRED: str | |
"secret_id": secret_id, # REQUIRED: str | |
"secret": { # REQUIRED: google.cloud.secretmanager_v1.types.Secret | |
"replication": { # OPTIONAL: google.cloud.secretmanager_v1.types.Replication | |
"automatic": {}, # OPTIONAL: google.cloud.secretmanager_v1.types.Replication.Automatic | |
"user_managed": { # OPTIONAL: and only if automatic is not specified: google.cloud.secretmanager_v1.types.Replication.UserManaged | |
"replicas": { # REQUIRED: with user_managed: MutableSequence[google.cloud.secretmanager_v1.types.Replication.UserManaged.Replica] | |
"location": location_id, # REQUIRED: str | |
"customer_managed_encryption": { # OPTIONAL: google.cloud.secretmanager_v1.types.CustomerManagedEncryption | |
"kms_key_name": kms_key_name # REQUIRED: The expected format is projects/*/locations/*/keyRings/*/cryptoKeys/* | |
} | |
} | |
}, | |
}, | |
"labels": label_list, # OPTIONAL: MutableMapping[str, str] | |
"topics": topic_list, # OPTIONAL: MutableSequence[google.cloud.secretmanager_v1.types.Topic] | |
"expire_time": timestamp # OPTIONAL: google.protobuf.timestamp_pb2.Timestamp | |
"ttl": ttl, # OPTIONAL: google.protobuf.duration_pb2.Duration | |
# .. and all the other properties .. | |
}, | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment