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

Commit

Permalink
update sample
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Sep 15, 2020
1 parent 5580e83 commit 9482a93
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions UPGRADING.md
Expand Up @@ -149,13 +149,16 @@ secret_version = secretmanager_v1.SecretVersion.ENABLED
secret = secretmanager_v1.Secret(name="name")
```

## Project Path Helper Method
## Path Helper Methods

Project path helper method has been removed. Please construct
the path manually.
The following path helper methods have been removed. Please construct
the paths manually.

```py
project = 'my-project'
secret = 'secret'
secret_version = 'secret_version'

project_path = f'projects/{project}'
secret_version_path = f'projects/{project}/secrets/{secret}/versions/{secret_version}'
```
2 changes: 1 addition & 1 deletion samples/snippets/access_secret_version.py
Expand Up @@ -33,7 +33,7 @@ def access_secret_version(project_id, secret_id, version_id):
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the secret version.
name = client.secret_version_path(project_id, secret_id, version_id)
name = f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'

# Access the secret version.
response = client.access_secret_version(request={'name': name})
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/destroy_secret_version.py
Expand Up @@ -33,7 +33,7 @@ def destroy_secret_version(project_id, secret_id, version_id):
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the secret version
name = client.secret_version_path(project_id, secret_id, version_id)
name = f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'

# Destroy the secret version.
response = client.destroy_secret_version(request={'name': name})
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/disable_secret_version.py
Expand Up @@ -33,7 +33,7 @@ def disable_secret_version(project_id, secret_id, version_id):
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the secret version
name = client.secret_version_path(project_id, secret_id, version_id)
name = f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'

# Disable the secret version.
response = client.disable_secret_version(request={'name': name})
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/enable_secret_version.py
Expand Up @@ -33,7 +33,7 @@ def enable_secret_version(project_id, secret_id, version_id):
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the secret version
name = client.secret_version_path(project_id, secret_id, version_id)
name = f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'

# Disable the secret version.
response = client.enable_secret_version(request={'name': name})
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/get_secret_version.py
Expand Up @@ -34,7 +34,7 @@ def get_secret_version(project_id, secret_id, version_id):
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the secret version.
name = client.secret_version_path(project_id, secret_id, version_id)
name = f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'

# Get the secret version.
response = client.get_secret_version(request={'name': name})
Expand Down
3 changes: 2 additions & 1 deletion samples/snippets/requirements.txt
@@ -1 +1,2 @@
google-cloud-secret-manager==1.0.0
#google-cloud-secret-manager==1.0.0
-e ./../../
2 changes: 1 addition & 1 deletion samples/snippets/snippets_test.py
Expand Up @@ -120,7 +120,7 @@ def test_delete_secret(client, secret):
delete_secret(project_id, secret_id)
with pytest.raises(exceptions.NotFound):
print('{}'.format(client))
name = client.secret_version_path(project_id, secret_id, 'latest')
name = f'projects/{project_id}/secrets/{secret_id}/versions/latest'
client.access_secret_version(request={'name': name})


Expand Down

0 comments on commit 9482a93

Please sign in to comment.