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

Commit

Permalink
feat: added expire_time and ttl fields to Secret
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 352563582

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Jan 19 07:29:20 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 9ecdacc9a00e1dd443b11bf10215d6e7648db8a7
Source-Link: googleapis/googleapis@9ecdacc
  • Loading branch information
yoshi-automation authored and busunkim96 committed Jan 20, 2021
1 parent 7326d5f commit f89222c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
Expand Up @@ -33,6 +33,7 @@
from google.cloud.secretmanager_v1.types import service
from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore
from google.iam.v1 import policy_pb2 as policy # type: ignore
from google.protobuf import duration_pb2 as duration # type: ignore
from google.protobuf import field_mask_pb2 as field_mask # type: ignore
from google.protobuf import timestamp_pb2 as timestamp # type: ignore

Expand Down
Expand Up @@ -37,6 +37,7 @@
from google.cloud.secretmanager_v1.types import service
from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore
from google.iam.v1 import policy_pb2 as policy # type: ignore
from google.protobuf import duration_pb2 as duration # type: ignore
from google.protobuf import field_mask_pb2 as field_mask # type: ignore
from google.protobuf import timestamp_pb2 as timestamp # type: ignore

Expand Down
17 changes: 17 additions & 0 deletions google/cloud/secretmanager_v1/types/resources.py
Expand Up @@ -18,6 +18,7 @@
import proto # type: ignore


from google.protobuf import duration_pb2 as duration # type: ignore
from google.protobuf import timestamp_pb2 as timestamp # type: ignore


Expand Down Expand Up @@ -73,6 +74,14 @@ class Secret(proto.Message):
``[\p{Ll}\p{Lo}\p{N}_-]{0,63}``
No more than 64 labels can be assigned to a given resource.
expire_time (google.protobuf.timestamp_pb2.Timestamp):
Optional. Timestamp in UTC when the
[Secret][google.cloud.secretmanager.v1.Secret] is scheduled
to expire. This is always provided on output, regardless of
what was sent on input.
ttl (google.protobuf.duration_pb2.Duration):
Input only. The TTL for the
[Secret][google.cloud.secretmanager.v1.Secret].
"""

name = proto.Field(proto.STRING, number=1)
Expand All @@ -83,6 +92,14 @@ class Secret(proto.Message):

labels = proto.MapField(proto.STRING, proto.STRING, number=4)

expire_time = proto.Field(
proto.MESSAGE, number=6, oneof="expiration", message=timestamp.Timestamp,
)

ttl = proto.Field(
proto.MESSAGE, number=7, oneof="expiration", message=duration.Duration,
)


class SecretVersion(proto.Message):
r"""A secret version resource in the Secret Manager API.
Expand Down
4 changes: 2 additions & 2 deletions synth.metadata
Expand Up @@ -11,8 +11,8 @@
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "520682435235d9c503983a360a2090025aa47cd1",
"internalRef": "350246057"
"sha": "9ecdacc9a00e1dd443b11bf10215d6e7648db8a7",
"internalRef": "352563582"
}
},
{
Expand Down
13 changes: 10 additions & 3 deletions tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py
Expand Up @@ -46,6 +46,7 @@
from google.iam.v1 import options_pb2 as options # type: ignore
from google.iam.v1 import policy_pb2 as policy # type: ignore
from google.oauth2 import service_account
from google.protobuf import duration_pb2 as duration # type: ignore
from google.protobuf import field_mask_pb2 as field_mask # type: ignore
from google.protobuf import timestamp_pb2 as timestamp # type: ignore
from google.type import expr_pb2 as expr # type: ignore
Expand Down Expand Up @@ -830,7 +831,9 @@ def test_create_secret(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.create_secret), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = resources.Secret(name="name_value",)
call.return_value = resources.Secret(
name="name_value", expire_time=timestamp.Timestamp(seconds=751),
)

response = client.create_secret(request)

Expand Down Expand Up @@ -1272,7 +1275,9 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_secret), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = resources.Secret(name="name_value",)
call.return_value = resources.Secret(
name="name_value", expire_time=timestamp.Timestamp(seconds=751),
)

response = client.get_secret(request)

Expand Down Expand Up @@ -1465,7 +1470,9 @@ def test_update_secret(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.update_secret), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = resources.Secret(name="name_value",)
call.return_value = resources.Secret(
name="name_value", expire_time=timestamp.Timestamp(seconds=751),
)

response = client.update_secret(request)

Expand Down

0 comments on commit f89222c

Please sign in to comment.