Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
encryption_config.h
Go to the documentation of this file.
1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ENCRYPTION_CONFIG_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ENCRYPTION_CONFIG_H
17 
18 #include "google/cloud/spanner/version.h"
19 #include "google/cloud/kms_key_name.h"
20 #include "absl/types/variant.h"
21 
22 namespace google {
23 namespace cloud {
24 namespace spanner {
25 inline namespace SPANNER_CLIENT_NS {
26 
27 /**
28  * Use the per-operation default encryption:
29  * - for `CreateDatabase()` use Google default encryption,
30  * - for `CreateBackup()` use the encryption of the source database,
31  * - for `RestoreDatabase()` use the encryption of the source backup.
32  */
34 
35 /**
36  * Use Google default encryption.
37  */
39 
40 /**
41  * Use encryption with `encryption_key`.
42  */
44  public:
45  explicit CustomerManagedEncryption(KmsKeyName encryption_key)
46  : encryption_key_(std::move(encryption_key)) {}
47 
48  KmsKeyName const& encryption_key() const { return encryption_key_; }
49 
50  private:
51  KmsKeyName encryption_key_;
52 };
53 
54 /**
55  * Specify the encryption configuration for any of the following operations:
56  * - `DatabaseAdminClient::CreateDatabase()`
57  * - `DatabaseAdminClient::CreateBackup()`
58  * - `DatabaseAdminClient::RestoreDatabase()`
59  */
60 using EncryptionConfig = absl::variant<DefaultEncryption, GoogleEncryption,
62 
63 } // namespace SPANNER_CLIENT_NS
64 } // namespace spanner
65 } // namespace cloud
66 } // namespace google
67 
68 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ENCRYPTION_CONFIG_H