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

feat: Etags in Secret Manager #116

Merged
merged 2 commits into from May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -783,8 +783,8 @@ async def get_secret_version(
r"""Gets metadata for a
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Args:
Expand All @@ -795,8 +795,9 @@ async def get_secret_version(
Required. The resource name of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to
the ``latest``
the most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

This corresponds to the ``name`` field
Expand Down Expand Up @@ -864,8 +865,8 @@ async def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
This call returns the secret data.

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Args:
Expand All @@ -877,6 +878,10 @@ async def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to
the most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand Down
Expand Up @@ -987,8 +987,8 @@ def get_secret_version(
r"""Gets metadata for a
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Args:
Expand All @@ -999,8 +999,9 @@ def get_secret_version(
Required. The resource name of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to
the ``latest``
the most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

This corresponds to the ``name`` field
Expand Down Expand Up @@ -1068,8 +1069,8 @@ def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
This call returns the secret data.

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Args:
Expand All @@ -1081,6 +1082,10 @@ def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to
the most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand Down
Expand Up @@ -429,8 +429,8 @@ def get_secret_version(
Gets metadata for a
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Returns:
Expand Down Expand Up @@ -463,8 +463,8 @@ def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
This call returns the secret data.

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Returns:
Expand Down
Expand Up @@ -441,8 +441,8 @@ def get_secret_version(
Gets metadata for a
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Returns:
Expand Down Expand Up @@ -476,8 +476,8 @@ def access_secret_version(
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
This call returns the secret data.

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
``projects/*/secrets/*/versions/latest`` is an alias to the most
recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].

Returns:
Expand Down
11 changes: 10 additions & 1 deletion google/cloud/secretmanager_v1/types/resources.py
Expand Up @@ -86,6 +86,9 @@ class Secret(proto.Message):
ttl (google.protobuf.duration_pb2.Duration):
Input only. The TTL for the
[Secret][google.cloud.secretmanager.v1.Secret].
etag (str):
Optional. Etag of the currently stored
[Secret][google.cloud.secretmanager.v1.Secret].
rotation (google.cloud.secretmanager_v1.types.Rotation):
Optional. Rotation policy attached to the
[Secret][google.cloud.secretmanager.v1.Secret]. May be
Expand All @@ -103,6 +106,7 @@ class Secret(proto.Message):
ttl = proto.Field(
proto.MESSAGE, number=7, oneof="expiration", message=duration_pb2.Duration,
)
etag = proto.Field(proto.STRING, number=8,)
rotation = proto.Field(proto.MESSAGE, number=9, message="Rotation",)


Expand Down Expand Up @@ -135,6 +139,9 @@ class SecretVersion(proto.Message):
replication_status (google.cloud.secretmanager_v1.types.ReplicationStatus):
The replication status of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
etag (str):
Output only. Etag of the currently stored
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
"""

class State(proto.Enum):
Expand All @@ -156,6 +163,7 @@ class State(proto.Enum):
replication_status = proto.Field(
proto.MESSAGE, number=5, message="ReplicationStatus",
)
etag = proto.Field(proto.STRING, number=6,)


class Replication(proto.Message):
Expand Down Expand Up @@ -408,7 +416,8 @@ class Rotation(proto.Message):
next_rotation_time (google.protobuf.timestamp_pb2.Timestamp):
Optional. Timestamp in UTC at which the
[Secret][google.cloud.secretmanager.v1.Secret] is scheduled
to rotate.
to rotate. Cannot be set to less than 300s (5 min) in the
future and at most 3153600000s (100 years).

[next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time]
MUST be set if
Expand Down
34 changes: 33 additions & 1 deletion google/cloud/secretmanager_v1/types/service.py
Expand Up @@ -219,8 +219,9 @@ class GetSecretVersionRequest(proto.Message):
Required. The resource name of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to the
``latest``
most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
"""

Expand Down Expand Up @@ -254,6 +255,10 @@ class AccessSecretVersionRequest(proto.Message):
Required. The resource name of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
in the format ``projects/*/secrets/*/versions/*``.

``projects/*/secrets/*/versions/latest`` is an alias to the
most recently created
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
"""

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

name = proto.Field(proto.STRING, number=1,)
etag = proto.Field(proto.STRING, number=2,)


class DisableSecretVersionRequest(proto.Message):
Expand All @@ -300,9 +311,16 @@ class DisableSecretVersionRequest(proto.Message):
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
to disable in the format
``projects/*/secrets/*/versions/*``.
etag (str):
Optional. Etag of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
The request succeeds if it matches the etag of the currently
stored secret version object. If the etag is omitted, the
request succeeds.
"""

name = proto.Field(proto.STRING, number=1,)
etag = proto.Field(proto.STRING, number=2,)


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

name = proto.Field(proto.STRING, number=1,)
etag = proto.Field(proto.STRING, number=2,)


class DestroySecretVersionRequest(proto.Message):
Expand All @@ -329,9 +354,16 @@ class DestroySecretVersionRequest(proto.Message):
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion]
to destroy in the format
``projects/*/secrets/*/versions/*``.
etag (str):
Optional. Etag of the
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
The request succeeds if it matches the etag of the currently
stored secret version object. If the etag is omitted, the
request succeeds.
"""

name = proto.Field(proto.STRING, number=1,)
etag = proto.Field(proto.STRING, number=2,)


__all__ = tuple(sorted(__protobuf__.manifest))
8 changes: 4 additions & 4 deletions scripts/fixup_secretmanager_v1_keywords.py
Expand Up @@ -42,10 +42,10 @@ class secretmanagerCallTransformer(cst.CSTTransformer):
'access_secret_version': ('name', ),
'add_secret_version': ('parent', 'payload', ),
'create_secret': ('parent', 'secret_id', 'secret', ),
'delete_secret': ('name', ),
'destroy_secret_version': ('name', ),
'disable_secret_version': ('name', ),
'enable_secret_version': ('name', ),
'delete_secret': ('name', 'etag', ),
'destroy_secret_version': ('name', 'etag', ),
'disable_secret_version': ('name', 'etag', ),
'enable_secret_version': ('name', 'etag', ),
'get_iam_policy': ('resource', 'options', ),
'get_secret': ('name', ),
'get_secret_version': ('name', ),
Expand Down