Skip to content

Commit 6ba4877

Browse files
committed
chore: add CMEK via synth
1 parent c98ed50 commit 6ba4877

17 files changed

+512
-96
lines changed

google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
database_admin_grpc_transport,
4141
)
4242
from google.cloud.spanner_admin_database_v1.proto import backup_pb2
43+
from google.cloud.spanner_admin_database_v1.proto import common_pb2
4344
from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2
4445
from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc
4546
from google.iam.v1 import iam_policy_pb2
@@ -100,6 +101,17 @@ def backup_path(cls, project, instance, backup):
100101
backup=backup,
101102
)
102103

104+
@classmethod
105+
def crypto_key_path(cls, project, location, key_ring, crypto_key):
106+
"""Return a fully-qualified crypto_key string."""
107+
return google.api_core.path_template.expand(
108+
"projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}",
109+
project=project,
110+
location=location,
111+
key_ring=key_ring,
112+
crypto_key=crypto_key,
113+
)
114+
103115
@classmethod
104116
def database_path(cls, project, instance, database):
105117
"""Return a fully-qualified database string."""
@@ -237,6 +249,7 @@ def create_database(
237249
parent,
238250
create_statement,
239251
extra_statements=None,
252+
encryption_config=None,
240253
retry=google.api_core.gapic_v1.method.DEFAULT,
241254
timeout=google.api_core.gapic_v1.method.DEFAULT,
242255
metadata=None,
@@ -282,6 +295,10 @@ def create_database(
282295
database. Statements can create tables, indexes, etc. These
283296
statements execute atomically with the creation of the database:
284297
if there is an error in any statement, the database is not created.
298+
encryption_config (Union[dict, ~google.cloud.spanner_admin_database_v1.types.EncryptionConfig]): Optional.
299+
300+
If a dict is provided, it must be of the same form as the protobuf
301+
message :class:`~google.cloud.spanner_admin_database_v1.types.EncryptionConfig`
285302
retry (Optional[google.api_core.retry.Retry]): A retry object used
286303
to retry requests. If ``None`` is specified, requests will
287304
be retried using a default configuration.
@@ -316,6 +333,7 @@ def create_database(
316333
parent=parent,
317334
create_statement=create_statement,
318335
extra_statements=extra_statements,
336+
encryption_config=encryption_config,
319337
)
320338
if metadata is None:
321339
metadata = []

google/cloud/spanner_admin_database_v1/gapic/enums.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,24 @@ class State(enum.IntEnum):
7272
CREATING = 1
7373
READY = 2
7474
READY_OPTIMIZING = 3
75+
76+
77+
class EncryptionInfo(object):
78+
class Type(enum.IntEnum):
79+
"""
80+
Possible encryption types for a resource.
81+
82+
Attributes:
83+
TYPE_UNSPECIFIED (int): Encryption type was not specified, though data at rest remains encrypted.
84+
GOOGLE_DEFAULT_ENCRYPTION (int): The data backing this resource is encrypted at rest with a key that is
85+
fully managed by Google. No key version or status will be populated.
86+
This is the default state.
87+
CUSTOMER_MANAGED_ENCRYPTION (int): The data backing this resource is encrypted at rest with a key that
88+
is managed by the customer. The active version of the key.
89+
'kms_key_version' will be populated, and 'encryption_status' may be
90+
populated.
91+
"""
92+
93+
TYPE_UNSPECIFIED = 0
94+
GOOGLE_DEFAULT_ENCRYPTION = 1
95+
CUSTOMER_MANAGED_ENCRYPTION = 2

google/cloud/spanner_admin_database_v1/proto/backup.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import "google/longrunning/operations.proto";
2222
import "google/protobuf/field_mask.proto";
2323
import "google/protobuf/timestamp.proto";
2424
import "google/spanner/admin/database/v1/common.proto";
25-
import "google/api/annotations.proto";
2625

2726
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
2827
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
@@ -104,6 +103,11 @@ message Backup {
104103
// restored database from the backup enters the `READY` state, the reference
105104
// to the backup is removed.
106105
repeated string referencing_databases = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
106+
107+
// Output only. The encryption information for the backup.
108+
// If the encryption key protecting this resource is customer managed, then
109+
// kms_key_version will be filled.
110+
EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
107111
}
108112

109113
// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].

google/cloud/spanner_admin_database_v1/proto/backup_pb2.py

Lines changed: 55 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)