Google Cloud C++ Client
2.7.0
C++ Client Library for Google Cloud Platform
kms_key_name.h
Go to the documentation of this file.
1
// Copyright 2020 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_KMS_KEY_NAME_H
16
#
define
GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_KMS_KEY_NAME_H
17
18
#
include
"google/cloud/status_or.h"
19
#
include
"google/cloud/version.h"
20
#
include
<
iosfwd
>
21
#
include
<
string
>
22
23
namespace
google
{
24
namespace
cloud
{
25
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
26
27
/**
28
* This class identifies a Google Cloud KMS Key
29
*
30
* A KMS key is identified by its `project_id`, `location`, `key_ring`,
31
* and `kms_key_name`.
32
*
33
* @note This class makes no effort to validate the components of the key,
34
* It is the application's responsibility to provide a valid project id,
35
* location, key ring, and KMS key name. Passing invalid values will not
36
* be checked until the key is used in a RPC.
37
*
38
* See https://cloud.google.com/kms/docs for more information on KMS.
39
*/
40
class
KmsKeyName
{
41
public
:
42
/**
43
* Constructs a KmsKeyName object identified by the given @p project_id,
44
* @p location, @p key_ring, and @p kms_key_name.
45
*/
46
KmsKeyName
(std::string
const
& project_id, std::string
const
& location,
47
std::string
const
& key_ring, std::string
const
& kms_key_name);
48
49
/// @name Copy and move
50
///@{
51
KmsKeyName
(
KmsKeyName
const
&) =
default
;
52
KmsKeyName
&
operator
=(
KmsKeyName
const
&) =
default
;
53
KmsKeyName
(
KmsKeyName
&&) =
default
;
54
KmsKeyName
&
operator
=(
KmsKeyName
&&) =
default
;
55
///@}
56
57
/**
58
* Returns the fully qualified KMS Key name as a string of the form:
59
* "projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys\
60
* /<kms_key_name>".
61
*/
62
std::string
const
&
FullName
()
const
{
return
full_name_; }
63
64
/// @name Equality operators
65
///@{
66
friend
bool
operator
==(
KmsKeyName
const
& a,
KmsKeyName
const
& b);
67
friend
bool
operator
!=(
KmsKeyName
const
& a,
KmsKeyName
const
& b) {
68
return
!(a
==
b);
69
}
70
71
///@}
72
/// Output the `FullName()` format.
73
friend
std::ostream& operator<<(std::ostream&,
KmsKeyName
const
&);
74
75
private
:
76
std::string full_name_;
77
};
78
79
/**
80
* Constructs a `KmsKeyName` from the given @p full_name.
81
* Returns a non-OK Status if `full_name` is improperly formed.
82
*/
83
StatusOr<
KmsKeyName
>
MakeKmsKeyName
(std::string
const
& full_name);
84
85
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
86
}
// namespace cloud
87
}
// namespace google
88
89
#
endif
// GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_KMS_KEY_NAME_H
Generated on Wed Feb 1 2023 20:24:29 for Google Cloud C++ Client by
1.9.1