Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 6ec898e

Browse files
feat: Etags in Secret Manager (#116)
* feat: Etags in Secret Manager Users can now use etags for optimistic concurrency control when modifying Secret or SecretVersion. PiperOrigin-RevId: 373836373 Source-Link: googleapis/googleapis@bff8074 Source-Link: https://github.com/googleapis/googleapis-gen/commit/174c036e0697d01dd21a22b210e820b602a00265 * 🦉 Updates from OwlBot Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 2d45c56 commit 6ec898e

File tree

8 files changed

+133
-40
lines changed

8 files changed

+133
-40
lines changed

google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ async def get_secret_version(
783783
r"""Gets metadata for a
784784
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
785785
786-
``projects/*/secrets/*/versions/latest`` is an alias to the
787-
``latest``
786+
``projects/*/secrets/*/versions/latest`` is an alias to the most
787+
recently created
788788
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
789789
790790
Args:
@@ -795,8 +795,9 @@ async def get_secret_version(
795795
Required. The resource name of the
796796
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
797797
in the format ``projects/*/secrets/*/versions/*``.
798+
798799
``projects/*/secrets/*/versions/latest`` is an alias to
799-
the ``latest``
800+
the most recently created
800801
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
801802
802803
This corresponds to the ``name`` field
@@ -864,8 +865,8 @@ async def access_secret_version(
864865
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
865866
This call returns the secret data.
866867
867-
``projects/*/secrets/*/versions/latest`` is an alias to the
868-
``latest``
868+
``projects/*/secrets/*/versions/latest`` is an alias to the most
869+
recently created
869870
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
870871
871872
Args:
@@ -877,6 +878,10 @@ async def access_secret_version(
877878
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
878879
in the format ``projects/*/secrets/*/versions/*``.
879880
881+
``projects/*/secrets/*/versions/latest`` is an alias to
882+
the most recently created
883+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
884+
880885
This corresponds to the ``name`` field
881886
on the ``request`` instance; if ``request`` is provided, this
882887
should not be set.

google/cloud/secretmanager_v1/services/secret_manager_service/client.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,8 @@ def get_secret_version(
987987
r"""Gets metadata for a
988988
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
989989
990-
``projects/*/secrets/*/versions/latest`` is an alias to the
991-
``latest``
990+
``projects/*/secrets/*/versions/latest`` is an alias to the most
991+
recently created
992992
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
993993
994994
Args:
@@ -999,8 +999,9 @@ def get_secret_version(
999999
Required. The resource name of the
10001000
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
10011001
in the format ``projects/*/secrets/*/versions/*``.
1002+
10021003
``projects/*/secrets/*/versions/latest`` is an alias to
1003-
the ``latest``
1004+
the most recently created
10041005
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
10051006
10061007
This corresponds to the ``name`` field
@@ -1068,8 +1069,8 @@ def access_secret_version(
10681069
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
10691070
This call returns the secret data.
10701071
1071-
``projects/*/secrets/*/versions/latest`` is an alias to the
1072-
``latest``
1072+
``projects/*/secrets/*/versions/latest`` is an alias to the most
1073+
recently created
10731074
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
10741075
10751076
Args:
@@ -1081,6 +1082,10 @@ def access_secret_version(
10811082
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
10821083
in the format ``projects/*/secrets/*/versions/*``.
10831084
1085+
``projects/*/secrets/*/versions/latest`` is an alias to
1086+
the most recently created
1087+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
1088+
10841089
This corresponds to the ``name`` field
10851090
on the ``request`` instance; if ``request`` is provided, this
10861091
should not be set.

google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ def get_secret_version(
429429
Gets metadata for a
430430
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
431431
432-
``projects/*/secrets/*/versions/latest`` is an alias to the
433-
``latest``
432+
``projects/*/secrets/*/versions/latest`` is an alias to the most
433+
recently created
434434
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
435435
436436
Returns:
@@ -463,8 +463,8 @@ def access_secret_version(
463463
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
464464
This call returns the secret data.
465465
466-
``projects/*/secrets/*/versions/latest`` is an alias to the
467-
``latest``
466+
``projects/*/secrets/*/versions/latest`` is an alias to the most
467+
recently created
468468
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
469469
470470
Returns:

google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ def get_secret_version(
441441
Gets metadata for a
442442
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
443443
444-
``projects/*/secrets/*/versions/latest`` is an alias to the
445-
``latest``
444+
``projects/*/secrets/*/versions/latest`` is an alias to the most
445+
recently created
446446
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
447447
448448
Returns:
@@ -476,8 +476,8 @@ def access_secret_version(
476476
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
477477
This call returns the secret data.
478478
479-
``projects/*/secrets/*/versions/latest`` is an alias to the
480-
``latest``
479+
``projects/*/secrets/*/versions/latest`` is an alias to the most
480+
recently created
481481
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
482482
483483
Returns:

google/cloud/secretmanager_v1/types/resources.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class Secret(proto.Message):
8686
ttl (google.protobuf.duration_pb2.Duration):
8787
Input only. The TTL for the
8888
[Secret][google.cloud.secretmanager.v1.Secret].
89+
etag (str):
90+
Optional. Etag of the currently stored
91+
[Secret][google.cloud.secretmanager.v1.Secret].
8992
rotation (google.cloud.secretmanager_v1.types.Rotation):
9093
Optional. Rotation policy attached to the
9194
[Secret][google.cloud.secretmanager.v1.Secret]. May be
@@ -103,6 +106,7 @@ class Secret(proto.Message):
103106
ttl = proto.Field(
104107
proto.MESSAGE, number=7, oneof="expiration", message=duration_pb2.Duration,
105108
)
109+
etag = proto.Field(proto.STRING, number=8,)
106110
rotation = proto.Field(proto.MESSAGE, number=9, message="Rotation",)
107111

108112

@@ -135,6 +139,9 @@ class SecretVersion(proto.Message):
135139
replication_status (google.cloud.secretmanager_v1.types.ReplicationStatus):
136140
The replication status of the
137141
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
142+
etag (str):
143+
Output only. Etag of the currently stored
144+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
138145
"""
139146

140147
class State(proto.Enum):
@@ -156,6 +163,7 @@ class State(proto.Enum):
156163
replication_status = proto.Field(
157164
proto.MESSAGE, number=5, message="ReplicationStatus",
158165
)
166+
etag = proto.Field(proto.STRING, number=6,)
159167

160168

161169
class Replication(proto.Message):
@@ -408,7 +416,8 @@ class Rotation(proto.Message):
408416
next_rotation_time (google.protobuf.timestamp_pb2.Timestamp):
409417
Optional. Timestamp in UTC at which the
410418
[Secret][google.cloud.secretmanager.v1.Secret] is scheduled
411-
to rotate.
419+
to rotate. Cannot be set to less than 300s (5 min) in the
420+
future and at most 3153600000s (100 years).
412421
413422
[next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time]
414423
MUST be set if

google/cloud/secretmanager_v1/types/service.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ class GetSecretVersionRequest(proto.Message):
219219
Required. The resource name of the
220220
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
221221
in the format ``projects/*/secrets/*/versions/*``.
222+
222223
``projects/*/secrets/*/versions/latest`` is an alias to the
223-
``latest``
224+
most recently created
224225
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
225226
"""
226227

@@ -254,6 +255,10 @@ class AccessSecretVersionRequest(proto.Message):
254255
Required. The resource name of the
255256
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
256257
in the format ``projects/*/secrets/*/versions/*``.
258+
259+
``projects/*/secrets/*/versions/latest`` is an alias to the
260+
most recently created
261+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
257262
"""
258263

259264
name = proto.Field(proto.STRING, number=1,)
@@ -285,9 +290,15 @@ class DeleteSecretRequest(proto.Message):
285290
Required. The resource name of the
286291
[Secret][google.cloud.secretmanager.v1.Secret] to delete in
287292
the format ``projects/*/secrets/*``.
293+
etag (str):
294+
Optional. Etag of the
295+
[Secret][google.cloud.secretmanager.v1.Secret]. The request
296+
succeeds if it matches the etag of the currently stored
297+
secret object. If the etag is omitted, the request succeeds.
288298
"""
289299

290300
name = proto.Field(proto.STRING, number=1,)
301+
etag = proto.Field(proto.STRING, number=2,)
291302

292303

293304
class DisableSecretVersionRequest(proto.Message):
@@ -300,9 +311,16 @@ class DisableSecretVersionRequest(proto.Message):
300311
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
301312
to disable in the format
302313
``projects/*/secrets/*/versions/*``.
314+
etag (str):
315+
Optional. Etag of the
316+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
317+
The request succeeds if it matches the etag of the currently
318+
stored secret version object. If the etag is omitted, the
319+
request succeeds.
303320
"""
304321

305322
name = proto.Field(proto.STRING, number=1,)
323+
etag = proto.Field(proto.STRING, number=2,)
306324

307325

308326
class EnableSecretVersionRequest(proto.Message):
@@ -314,9 +332,16 @@ class EnableSecretVersionRequest(proto.Message):
314332
Required. The resource name of the
315333
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
316334
to enable in the format ``projects/*/secrets/*/versions/*``.
335+
etag (str):
336+
Optional. Etag of the
337+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
338+
The request succeeds if it matches the etag of the currently
339+
stored secret version object. If the etag is omitted, the
340+
request succeeds.
317341
"""
318342

319343
name = proto.Field(proto.STRING, number=1,)
344+
etag = proto.Field(proto.STRING, number=2,)
320345

321346

322347
class DestroySecretVersionRequest(proto.Message):
@@ -329,9 +354,16 @@ class DestroySecretVersionRequest(proto.Message):
329354
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
330355
to destroy in the format
331356
``projects/*/secrets/*/versions/*``.
357+
etag (str):
358+
Optional. Etag of the
359+
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
360+
The request succeeds if it matches the etag of the currently
361+
stored secret version object. If the etag is omitted, the
362+
request succeeds.
332363
"""
333364

334365
name = proto.Field(proto.STRING, number=1,)
366+
etag = proto.Field(proto.STRING, number=2,)
335367

336368

337369
__all__ = tuple(sorted(__protobuf__.manifest))

scripts/fixup_secretmanager_v1_keywords.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class secretmanagerCallTransformer(cst.CSTTransformer):
4242
'access_secret_version': ('name', ),
4343
'add_secret_version': ('parent', 'payload', ),
4444
'create_secret': ('parent', 'secret_id', 'secret', ),
45-
'delete_secret': ('name', ),
46-
'destroy_secret_version': ('name', ),
47-
'disable_secret_version': ('name', ),
48-
'enable_secret_version': ('name', ),
45+
'delete_secret': ('name', 'etag', ),
46+
'destroy_secret_version': ('name', 'etag', ),
47+
'disable_secret_version': ('name', 'etag', ),
48+
'enable_secret_version': ('name', 'etag', ),
4949
'get_iam_policy': ('resource', 'options', ),
5050
'get_secret': ('name', ),
5151
'get_secret_version': ('name', ),

0 commit comments

Comments
 (0)