-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathSecretManagerOperations.java
More file actions
261 lines (238 loc) · 10 KB
/
Copy pathSecretManagerOperations.java
File metadata and controls
261 lines (238 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/*
* Copyright 2017-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.spring.secretmanager;
/**
* Describes supported operations that one can perform on the Secret Manager API.
*
* <p>For some methods you may specify the secret from GCP Secret Manager by URI string. The
* following secret URI syntax is supported:
*
* <p>1. Long form - specify the project ID, secret ID, and version
* sm://projects/{project-id}/secrets/{secret-id}/versions/{version-id}
*
* <p>2. Long form - specify project ID, secret ID, and use latest version
* sm://projects/{project-id}/secrets/{secret-id}
*
* <p>3. Short form - specify project ID, secret ID, and version
* sm://{project-id}/{secret-id}/{version-id}
*
* <p>4. Short form - specify secret and version, use default GCP project configured
* sm://{secret-id}/{version}
*
* <p>5. Shortest form - specify secret ID, use default project and latest version. sm://{secret-id}
*
* @since 1.2.2
*/
public interface SecretManagerOperations {
/**
* Creates a new secret or a new version of existing secret with the provided {@code payload}.
*
* <p>If there is already a secret saved in SecretManager with the specified {@code secretId},
* then it simply creates a new version under the secret with the secret {@code payload}.
*
* @param secretId the secret ID of the secret to create.
* @param payload the secret payload string.
*/
void createSecret(String secretId, String payload);
/**
* Creates a new secret or a new version of existing secret with the provided {@code payload}.
*
* <p>If there is already a secret saved in SecretManager with the specified {@code secretId},
* then it simply creates a new version under the secret with the secret {@code payload}.
*
* @param secretId the secret ID of the secret to create.
* @param payload the secret payload string.
* @param locationId the secret location string.
*/
void createSecret(String secretId, String payload, String locationId);
/**
* Creates a new secret or a new version of existing secret with the provided {@code payload}.
*
* <p>If there is already a secret saved in SecretManager with the specified {@code secretId},
* then it simply creates a new version under the secret with the secret {@code payload}.
*
* @param secretId the secret ID of the secret to create.
* @param payload the secret payload as a byte array.
*/
void createSecret(String secretId, byte[] payload);
/**
* Creates a new secret or a new version of existing secret with the provided {@code payload} for
* a specific {@code projectId}.
*
* <p>If there is already a secret saved in SecretManager with the specified {@code secretId},
* then it simply creates a new version under the secret with the secret {@code payload}.
*
* @param secretId the secret ID of the secret to create.
* @param payload the secret payload as a byte array.
* @param projectId unique identifier of your project.
*/
void createSecret(String secretId, byte[] payload, String projectId);
/**
* Creates a new secret or a new version of existing secret with the provided {@code payload} for
* a specific {@code projectId}.
*
* <p>If there is already a secret saved in SecretManager with the specified {@code secretId},
* then it simply creates a new version under the secret with the secret {@code payload}.
*
* @param secretId the secret ID of the secret to create.
* @param payload the secret payload as a byte array.
* @param projectId unique identifier of your project.
* @param locationId the secret location string.
*/
void createSecret(String secretId, byte[] payload, String projectId, String locationId);
/**
* Enables the specified secret version under the default-configured project.
*
* @param secretId the secret ID of the secret to enable.
* @param version the version to enable
*/
void enableSecretVersion(String secretId, String version);
/**
* Enables the secret version under the specified project.
*
* @param secretId the secret ID of the secret to enable.
* @param version the version to enable
* @param projectId unique identifier of your project.
*/
void enableSecretVersion(String secretId, String version, String projectId);
/**
* Enables the secret version under the specified project.
*
* @param secretId the secret ID of the secret to enable.
* @param version the version to enable
* @param projectId unique identifier of your project.
* @param locationId the secret location string.
*/
void enableSecretVersion(String secretId, String version, String projectId, String locationId);
/**
* Disables the specified secret version under the default-configured project.
*
* @param secretId the secret ID of the secret to disable.
* @param version the version to disable
*/
void disableSecretVersion(String secretId, String version);
/**
* Disables the secret version under the specified project.
*
* @param secretId the secret ID of the secret to disable.
* @param version the version to disable
* @param projectId unique identifier of your project.
*/
void disableSecretVersion(String secretId, String version, String projectId);
/**
* Disables the secret version under the specified project.
*
* @param secretId the secret ID of the secret to disable.
* @param version the version to disable
* @param projectId unique identifier of your project.
* @param locationId the secret location string.
*/
void disableSecretVersion(String secretId, String version, String projectId, String locationId);
/**
* Deletes the specified secret under the default-configured project.
*
* @param secretId the secret ID of the secret to delete.
*/
void deleteSecret(String secretId);
/**
* Deletes the specified secret.
*
* @param secretId the secret ID of the secret to delete.
* @param projectId the GCP project containing the secret to delete.
*/
void deleteSecret(String secretId, String projectId);
/**
* Deletes the specified secret.
*
* @param secretId the secret ID of the secret to delete.
* @param projectId the GCP project containing the secret to delete.
* @param locationId the secret location string.
*/
void deleteSecret(String secretId, String projectId, String locationId);
/**
* Deletes the specified secret version.
*
* @param secretId the secret ID of the secret to delete.
* @param version the version to delete
* @param projectId the GCP project containing the secret to delete.
*/
void deleteSecretVersion(String secretId, String version, String projectId);
/**
* Deletes the specified secret version.
*
* @param secretId the secret ID of the secret to delete.
* @param version the version to delete
* @param projectId the GCP project containing the secret to delete.
* @param locationId the secret location string.
*/
void deleteSecretVersion(String secretId, String version, String projectId, String locationId);
/**
* Gets the secret payload of the specified {@code secretIdentifier} secret.
*
* <p>The {@code secretIdentifier} must either be a secret ID or a fully qualified `sm://`
* protocol string which specifies the secret (see javadocs of {@link SecretManagerOperations} for
* the protocol format).
*
* <p>If the secret ID string is passed in, then this will return the payload of the secret for
* the default project at the latest version.
*
* @param secretIdentifier the GCP secret ID of the secret or a sm:// formatted string specifying
* the secret.
* @return The secret payload as String
*/
String getSecretString(String secretIdentifier);
/**
* Gets the secret payload of the specified {@code secretIdentifier} secret.
*
* <p>The {@code secretIdentifier} must either be a secret ID or a fully qualified `sm://`
* protocol string which specifies the secret (see javadocs of {@link SecretManagerOperations} for
* the protocol format).
*
* <p>If the secret ID string is passed in, then this will return the payload of the secret for
* the default project at the latest version.
*
* @param secretIdentifier the GCP secret ID of the secret or a sm:// formatted string specifying
* the secret.
* @return The secret payload as byte array
*/
byte[] getSecretBytes(String secretIdentifier);
/**
* Returns true if there already exists a secret under the GCP project with the {@code secretId}.
*
* @param secretId unique identifier of your secret in Secret Manager.
* @return true if the secret exists in Secret Manager; false otherwise
*/
boolean secretExists(String secretId);
/**
* Returns true if there already exists a secret under the GCP {@code projectId} with the {@code
* secretId}.
*
* @param secretId unique identifier of your secret in Secret Manager.
* @param projectId unique identifier of your project.
* @return true if the secret exists in Secret Manager; false otherwise
*/
boolean secretExists(String secretId, String projectId);
/**
* Returns true if there already exists a secret under the GCP {@code projectId} with the {@code
* secretId}.
*
* @param secretId unique identifier of your secret in Secret Manager.
* @param projectId unique identifier of your project.
* @param locationId the secret location string.
* @return true if the secret exists in Secret Manager; false otherwise
*/
boolean secretExists(String secretId, String projectId, String locationId);
}