Skip to content

Commit 0dc1b26

Browse files
committed
fix Update the delayed destroy samples.
1 parent 1031e1c commit 0dc1b26

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

secretmanager/snippets/regional_samples/create_regional_secret_with_delayed_destroy.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2024 Google LLC
3+
# Copyright 2025 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -36,7 +36,16 @@ def create_regional_secret_with_delayed_destroy(
3636
Create a new secret with the given name and version_destroy_ttl. A secret is a logical wrapper
3737
around a collection of secret versions. Secret versions hold the actual
3838
secret material.
39-
"""
39+
40+
Args:
41+
project_id: Parent project id
42+
location_id: Location of the secret
43+
secret_id: ID of the secret or fully qualified identifier for the secret
44+
version_destroy_ttl: Secret Version TTL after destruction request
45+
46+
Returns:
47+
Regional secret with delayed destroy
48+
"""
4049

4150
# Endpoint to call the regional secret manager sever
4251
api_endpoint = f"secretmanager.{location_id}.rep.googleapis.com"
@@ -76,10 +85,10 @@ def create_regional_secret_with_delayed_destroy(
7685
)
7786
parser.add_argument("secret_id", help="id of the secret to create")
7887
parser.add_argument(
79-
"version_destroy_ttl", help="version_destroy_ttl you want to add"
88+
"version_destroy_ttl", help="version_destroy_ttl you want to add (in seconds)"
8089
)
8190
args = parser.parse_args()
8291

8392
create_regional_secret_with_delayed_destroy(
84-
args.project_id, args.location_id, args.secret_id, args.version_destroy_ttl
93+
args.project_id, args.location_id, args.secret_id, int(args.version_destroy_ttl)
8594
)

secretmanager/snippets/regional_samples/disable_regional_secret_delayed_destroy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2024 Google LLC
3+
# Copyright 2025 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -26,6 +26,14 @@ def disable_regional_secret_delayed_destroy(
2626
) -> secretmanager_v1.Secret:
2727
"""
2828
Disable delayed destroy on an existing secret with a version destroy ttl.
29+
30+
Args:
31+
project_id: Parent project id
32+
location_id: Location of the secret
33+
secret_id: ID of the secret or fully qualified identifier for the secret
34+
35+
Returns:
36+
Regional secret with disabled delayed destroy
2937
"""
3038

3139
# Endpoint to call the regional secret manager sever

secretmanager/snippets/regional_samples/update_regional_secret_with_delayed_destroy.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2024 Google LLC
3+
# Copyright 2025 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -24,9 +24,18 @@
2424

2525
def update_regional_secret_with_delayed_destroy(
2626
project_id: str, location_id: str, secret_id: str, new_version_destroy_ttl: int
27-
) -> secretmanager_v1.UpdateSecretRequest:
27+
) -> secretmanager_v1.Secret:
2828
"""
2929
Update the version destroy ttl on an existing secret.
30+
31+
Args:
32+
project_id: Parent project id
33+
location_id: Location of the secret
34+
secret_id: ID of the secret or fully qualified identifier for the secret
35+
new_version_destroy_ttl: Secret Version TTL value in seconds
36+
37+
Returns:
38+
Regional secret with updated version destroy ttl value
3039
"""
3140

3241
# Endpoint to call the regional secret manager sever
@@ -68,10 +77,10 @@ def update_regional_secret_with_delayed_destroy(
6877
)
6978
parser.add_argument("secret_id", help="id of the secret to act on")
7079
parser.add_argument(
71-
"version_destroy_ttl", help="version_destroy_ttl you want to add"
80+
"new_version_destroy_ttl", help="version_destroy_ttl you want to add (in seconds)"
7281
)
7382
args = parser.parse_args()
7483

7584
update_regional_secret_with_delayed_destroy(
76-
args.project_id, args.location_id, args.secret_id, args.version_destroy_ttl
85+
args.project_id, args.location_id, args.secret_id, int(args.new_version_destroy_ttl)
7786
)

0 commit comments

Comments
 (0)