Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
encryption_config.h
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// https://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
22namespace google {
23namespace cloud {
24namespace spanner {
25GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
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 */
33class DefaultEncryption {};
34
35/**
36 * Use Google default encryption.
37 */
38class GoogleEncryption {};
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 */
60using EncryptionConfig = absl::variant<DefaultEncryption, GoogleEncryption,
62
63GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
64} // namespace spanner
65} // namespace cloud
66} // namespace google
67
68#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ENCRYPTION_CONFIG_H
KmsKeyName(KmsKeyName &&)=default
Use encryption with encryption_key.
Definition: encryption_config.h:43
KmsKeyName const & encryption_key() const
Definition: encryption_config.h:48
CustomerManagedEncryption(KmsKeyName encryption_key)
Definition: encryption_config.h:45
Use the per-operation default encryption:
Definition: encryption_config.h:33
Use Google default encryption.
Definition: encryption_config.h:38
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23