From 9482a933ed35ecdaef81e669d432233b3dc180f7 Mon Sep 17 00:00:00 2001 From: arithmetic1728 Date: Mon, 14 Sep 2020 18:09:00 -0700 Subject: [PATCH] update sample --- UPGRADING.md | 9 ++++++--- samples/snippets/access_secret_version.py | 2 +- samples/snippets/destroy_secret_version.py | 2 +- samples/snippets/disable_secret_version.py | 2 +- samples/snippets/enable_secret_version.py | 2 +- samples/snippets/get_secret_version.py | 2 +- samples/snippets/requirements.txt | 3 ++- samples/snippets/snippets_test.py | 2 +- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 08e50330..e810d13b 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -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}' ``` \ No newline at end of file diff --git a/samples/snippets/access_secret_version.py b/samples/snippets/access_secret_version.py index 1bd3da9a..1b61f607 100644 --- a/samples/snippets/access_secret_version.py +++ b/samples/snippets/access_secret_version.py @@ -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}) diff --git a/samples/snippets/destroy_secret_version.py b/samples/snippets/destroy_secret_version.py index 1192318d..98c48ac0 100644 --- a/samples/snippets/destroy_secret_version.py +++ b/samples/snippets/destroy_secret_version.py @@ -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}) diff --git a/samples/snippets/disable_secret_version.py b/samples/snippets/disable_secret_version.py index c1ce1113..48916caf 100644 --- a/samples/snippets/disable_secret_version.py +++ b/samples/snippets/disable_secret_version.py @@ -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}) diff --git a/samples/snippets/enable_secret_version.py b/samples/snippets/enable_secret_version.py index e9771e57..33dfc1e0 100644 --- a/samples/snippets/enable_secret_version.py +++ b/samples/snippets/enable_secret_version.py @@ -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}) diff --git a/samples/snippets/get_secret_version.py b/samples/snippets/get_secret_version.py index 37b82e19..f510b704 100644 --- a/samples/snippets/get_secret_version.py +++ b/samples/snippets/get_secret_version.py @@ -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}) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index da667b1c..9542bce2 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1,2 @@ -google-cloud-secret-manager==1.0.0 +#google-cloud-secret-manager==1.0.0 +-e ./../../ \ No newline at end of file diff --git a/samples/snippets/snippets_test.py b/samples/snippets/snippets_test.py index 00f56cdc..09ae1062 100644 --- a/samples/snippets/snippets_test.py +++ b/samples/snippets/snippets_test.py @@ -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})