diff --git a/.coveragerc b/.coveragerc index 2287362..7027a37 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,8 +10,3 @@ exclude_lines = pragma: NO COVER # Ignore debug-only repr def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index 4de26d0..bf0514c 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -21,6 +21,9 @@ deep-remove-regex: deep-copy-regex: - source: /google/cloud/secretmanager/(v.*)/.*-py/(.*) dest: /owl-bot-staging/$1/$2 + - source: /google/cloud/secrets/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + begin-after-commit-hash: 219c70cd9e899bc85b467a0557b3237d4c0a41ca diff --git a/docs/secretmanager_v1beta1/secret_manager_service.rst b/docs/secretmanager_v1beta1/secret_manager_service.rst index cec4d4e..cc67257 100644 --- a/docs/secretmanager_v1beta1/secret_manager_service.rst +++ b/docs/secretmanager_v1beta1/secret_manager_service.rst @@ -5,7 +5,6 @@ SecretManagerService :members: :inherited-members: - .. automodule:: google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers :members: :inherited-members: diff --git a/docs/secretmanager_v1beta1/types.rst b/docs/secretmanager_v1beta1/types.rst index 7e8f6e1..af33251 100644 --- a/docs/secretmanager_v1beta1/types.rst +++ b/docs/secretmanager_v1beta1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Secretmanager v1beta1 API .. automodule:: google.cloud.secretmanager_v1beta1.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/secretmanager_v1/gapic_version.py b/google/cloud/secretmanager_v1/gapic_version.py new file mode 100644 index 0000000..6e0128e --- /dev/null +++ b/google/cloud/secretmanager_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.12.6" # {x-release-please-version} diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py b/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py index 60c30d9..3f0b509 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py @@ -34,7 +34,8 @@ from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -import pkg_resources + +from google.cloud.secretmanager_v1 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -239,7 +240,7 @@ async def list_secrets( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretsAsyncPager: r"""Lists [Secrets][google.cloud.secretmanager.v1.Secret]. @@ -358,7 +359,7 @@ async def create_secret( secret_id: Optional[str] = None, secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1.Secret] @@ -493,7 +494,7 @@ async def add_secret_version( parent: Optional[str] = None, payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Creates a new @@ -610,7 +611,7 @@ async def get_secret( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Gets metadata for a given @@ -720,7 +721,7 @@ async def update_secret( secret: Optional[resources.Secret] = None, update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Updates metadata of an existing @@ -838,7 +839,7 @@ async def delete_secret( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. @@ -929,7 +930,7 @@ async def list_secret_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretVersionsAsyncPager: r"""Lists @@ -1049,7 +1050,7 @@ async def get_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a @@ -1161,7 +1162,7 @@ async def access_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a @@ -1284,7 +1285,7 @@ async def disable_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Disables a @@ -1395,7 +1396,7 @@ async def enable_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Enables a @@ -1506,7 +1507,7 @@ async def destroy_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Destroys a @@ -1617,7 +1618,7 @@ async def set_iam_policy( request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces @@ -1766,7 +1767,7 @@ async def get_iam_policy( request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. @@ -1911,7 +1912,7 @@ async def test_iam_permissions( request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. @@ -2003,14 +2004,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("SecretManagerServiceAsyncClient",) diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/client.py b/google/cloud/secretmanager_v1/services/secret_manager_service/client.py index 44f72e4..9ebb665 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/client.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/client.py @@ -38,7 +38,8 @@ from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.oauth2 import service_account # type: ignore -import pkg_resources + +from google.cloud.secretmanager_v1 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -493,7 +494,7 @@ def list_secrets( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretsPager: r"""Lists [Secrets][google.cloud.secretmanager.v1.Secret]. @@ -612,7 +613,7 @@ def create_secret( secret_id: Optional[str] = None, secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1.Secret] @@ -747,7 +748,7 @@ def add_secret_version( parent: Optional[str] = None, payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Creates a new @@ -864,7 +865,7 @@ def get_secret( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Gets metadata for a given @@ -974,7 +975,7 @@ def update_secret( secret: Optional[resources.Secret] = None, update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Updates metadata of an existing @@ -1092,7 +1093,7 @@ def delete_secret( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. @@ -1183,7 +1184,7 @@ def list_secret_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretVersionsPager: r"""Lists @@ -1303,7 +1304,7 @@ def get_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a @@ -1415,7 +1416,7 @@ def access_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a @@ -1528,7 +1529,7 @@ def disable_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Disables a @@ -1639,7 +1640,7 @@ def enable_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Enables a @@ -1750,7 +1751,7 @@ def destroy_secret_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Destroys a @@ -1861,7 +1862,7 @@ def set_iam_policy( request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces @@ -2009,7 +2010,7 @@ def get_iam_policy( request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. @@ -2153,7 +2154,7 @@ def test_iam_permissions( request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. @@ -2251,14 +2252,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("SecretManagerServiceClient",) diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py index db09413..0990e04 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py @@ -26,18 +26,13 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore -import pkg_resources +from google.cloud.secretmanager_v1 import gapic_version as package_version from google.cloud.secretmanager_v1.types import resources, service -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class SecretManagerServiceTransport(abc.ABC): diff --git a/google/cloud/secretmanager_v1beta1/__init__.py b/google/cloud/secretmanager_v1beta1/__init__.py index bbfe353..9c9a7a9 100644 --- a/google/cloud/secretmanager_v1beta1/__init__.py +++ b/google/cloud/secretmanager_v1beta1/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,8 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.secretmanager import gapic_version as package_version + +__version__ = package_version.__version__ + -from .services.secret_manager_service import SecretManagerServiceClient +from .services.secret_manager_service import ( + SecretManagerServiceAsyncClient, + SecretManagerServiceClient, +) from .types.resources import Replication, Secret, SecretPayload, SecretVersion from .types.service import ( AccessSecretVersionRequest, @@ -36,6 +42,7 @@ ) __all__ = ( + "SecretManagerServiceAsyncClient", "AccessSecretVersionRequest", "AccessSecretVersionResponse", "AddSecretVersionRequest", @@ -52,8 +59,8 @@ "ListSecretsResponse", "Replication", "Secret", + "SecretManagerServiceClient", "SecretPayload", "SecretVersion", "UpdateSecretRequest", - "SecretManagerServiceClient", ) diff --git a/google/cloud/secretmanager_v1beta1/gapic_metadata.json b/google/cloud/secretmanager_v1beta1/gapic_metadata.json new file mode 100644 index 0000000..7528c1a --- /dev/null +++ b/google/cloud/secretmanager_v1beta1/gapic_metadata.json @@ -0,0 +1,173 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.secretmanager_v1beta1", + "protoPackage": "google.cloud.secrets.v1beta1", + "schema": "1.0", + "services": { + "SecretManagerService": { + "clients": { + "grpc": { + "libraryClient": "SecretManagerServiceClient", + "rpcs": { + "AccessSecretVersion": { + "methods": [ + "access_secret_version" + ] + }, + "AddSecretVersion": { + "methods": [ + "add_secret_version" + ] + }, + "CreateSecret": { + "methods": [ + "create_secret" + ] + }, + "DeleteSecret": { + "methods": [ + "delete_secret" + ] + }, + "DestroySecretVersion": { + "methods": [ + "destroy_secret_version" + ] + }, + "DisableSecretVersion": { + "methods": [ + "disable_secret_version" + ] + }, + "EnableSecretVersion": { + "methods": [ + "enable_secret_version" + ] + }, + "GetIamPolicy": { + "methods": [ + "get_iam_policy" + ] + }, + "GetSecret": { + "methods": [ + "get_secret" + ] + }, + "GetSecretVersion": { + "methods": [ + "get_secret_version" + ] + }, + "ListSecretVersions": { + "methods": [ + "list_secret_versions" + ] + }, + "ListSecrets": { + "methods": [ + "list_secrets" + ] + }, + "SetIamPolicy": { + "methods": [ + "set_iam_policy" + ] + }, + "TestIamPermissions": { + "methods": [ + "test_iam_permissions" + ] + }, + "UpdateSecret": { + "methods": [ + "update_secret" + ] + } + } + }, + "grpc-async": { + "libraryClient": "SecretManagerServiceAsyncClient", + "rpcs": { + "AccessSecretVersion": { + "methods": [ + "access_secret_version" + ] + }, + "AddSecretVersion": { + "methods": [ + "add_secret_version" + ] + }, + "CreateSecret": { + "methods": [ + "create_secret" + ] + }, + "DeleteSecret": { + "methods": [ + "delete_secret" + ] + }, + "DestroySecretVersion": { + "methods": [ + "destroy_secret_version" + ] + }, + "DisableSecretVersion": { + "methods": [ + "disable_secret_version" + ] + }, + "EnableSecretVersion": { + "methods": [ + "enable_secret_version" + ] + }, + "GetIamPolicy": { + "methods": [ + "get_iam_policy" + ] + }, + "GetSecret": { + "methods": [ + "get_secret" + ] + }, + "GetSecretVersion": { + "methods": [ + "get_secret_version" + ] + }, + "ListSecretVersions": { + "methods": [ + "list_secret_versions" + ] + }, + "ListSecrets": { + "methods": [ + "list_secrets" + ] + }, + "SetIamPolicy": { + "methods": [ + "set_iam_policy" + ] + }, + "TestIamPermissions": { + "methods": [ + "test_iam_permissions" + ] + }, + "UpdateSecret": { + "methods": [ + "update_secret" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/secretmanager_v1beta1/gapic_version.py b/google/cloud/secretmanager_v1beta1/gapic_version.py new file mode 100644 index 0000000..6e0128e --- /dev/null +++ b/google/cloud/secretmanager_v1beta1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.12.6" # {x-release-please-version} diff --git a/google/cloud/secretmanager_v1beta1/services/__init__.py b/google/cloud/secretmanager_v1beta1/services/__init__.py index 42ffdf2..e8e1c38 100644 --- a/google/cloud/secretmanager_v1beta1/services/__init__.py +++ b/google/cloud/secretmanager_v1beta1/services/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/__init__.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/__init__.py index 82ea223..9a445a1 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/__init__.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .async_client import SecretManagerServiceAsyncClient from .client import SecretManagerServiceClient diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py index d2f3de5..c5af39e 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,23 +13,39 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union - -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -import google.api_core.client_options as ClientOptions # type: ignore -from google.auth import credentials # type: ignore -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 typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -import pkg_resources + +from google.cloud.secretmanager_v1beta1 import gapic_version as package_version + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.secretmanager_v1beta1.services.secret_manager_service import pagers from google.cloud.secretmanager_v1beta1.types import resources, service @@ -61,31 +76,26 @@ class SecretManagerServiceAsyncClient: parse_secret_version_path = staticmethod( SecretManagerServiceClient.parse_secret_version_path ) - common_billing_account_path = staticmethod( SecretManagerServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( SecretManagerServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(SecretManagerServiceClient.common_folder_path) parse_common_folder_path = staticmethod( SecretManagerServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( SecretManagerServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( SecretManagerServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(SecretManagerServiceClient.common_project_path) parse_common_project_path = staticmethod( SecretManagerServiceClient.parse_common_project_path ) - common_location_path = staticmethod(SecretManagerServiceClient.common_location_path) parse_common_location_path = staticmethod( SecretManagerServiceClient.parse_common_location_path @@ -93,7 +103,8 @@ class SecretManagerServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -108,7 +119,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -123,9 +134,45 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SecretManagerServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SecretManagerServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: SecretManagerServiceTransport: The transport used by the client instance. @@ -140,12 +187,12 @@ def transport(self) -> SecretManagerServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, SecretManagerServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the secret manager service client. + """Instantiates the secret manager service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -177,7 +224,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = SecretManagerServiceClient( credentials=credentials, transport=transport, @@ -187,17 +233,44 @@ def __init__( async def list_secrets( self, - request: Union[service.ListSecretsRequest, dict] = None, + request: Optional[Union[service.ListSecretsRequest, dict]] = None, *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretsAsyncPager: r"""Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_list_secrets(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secrets(request=request) + + # Handle the response + async for response in page_result: + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.ListSecretsRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.ListSecretsRequest, dict]]): The request object. Request message for [SecretManagerService.ListSecrets][google.cloud.secrets.v1beta1.SecretManagerService.ListSecrets]. parent (:class:`str`): @@ -208,7 +281,6 @@ async def list_secrets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -225,7 +297,7 @@ async def list_secrets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -238,7 +310,6 @@ async def list_secrets( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -278,21 +349,48 @@ async def list_secrets( async def create_secret( self, - request: Union[service.CreateSecretRequest, dict] = None, + request: Optional[Union[service.CreateSecretRequest, dict]] = None, *, - parent: str = None, - secret_id: str = None, - secret: resources.Secret = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + secret_id: Optional[str] = None, + secret: Optional[resources.Secret] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_create_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.CreateSecretRequest( + parent="parent_value", + secret_id="secret_id_value", + ) + + # Make the request + response = await client.create_secret(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.CreateSecretRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.CreateSecretRequest, dict]]): The request object. Request message for [SecretManagerService.CreateSecret][google.cloud.secrets.v1beta1.SecretManagerService.CreateSecret]. parent (:class:`str`): @@ -322,7 +420,6 @@ async def create_secret( This corresponds to the ``secret`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -341,7 +438,7 @@ async def create_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, secret_id, secret]) if request is not None and has_flattened_params: @@ -354,7 +451,6 @@ async def create_secret( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if secret_id is not None: @@ -389,12 +485,12 @@ async def create_secret( async def add_secret_version( self, - request: Union[service.AddSecretVersionRequest, dict] = None, + request: Optional[Union[service.AddSecretVersionRequest, dict]] = None, *, - parent: str = None, - payload: resources.SecretPayload = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + payload: Optional[resources.SecretPayload] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Creates a new @@ -402,8 +498,34 @@ async def add_secret_version( containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_add_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AddSecretVersionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.add_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.AddSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.AddSecretVersion]. parent (:class:`str`): @@ -423,7 +545,6 @@ async def add_secret_version( This corresponds to the ``payload`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -437,7 +558,7 @@ async def add_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, payload]) if request is not None and has_flattened_params: @@ -450,7 +571,6 @@ async def add_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if payload is not None: @@ -483,18 +603,44 @@ async def add_secret_version( async def get_secret( self, - request: Union[service.GetSecretRequest, dict] = None, + request: Optional[Union[service.GetSecretRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_get_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretRequest( + name="name_value", + ) + + # Make the request + response = await client.get_secret(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.GetSecretRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.GetSecretRequest, dict]]): The request object. Request message for [SecretManagerService.GetSecret][google.cloud.secrets.v1beta1.SecretManagerService.GetSecret]. name (:class:`str`): @@ -505,7 +651,6 @@ async def get_secret( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -524,7 +669,7 @@ async def get_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -537,7 +682,6 @@ async def get_secret( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -568,19 +712,44 @@ async def get_secret( async def update_secret( self, - request: service.UpdateSecretRequest = None, + request: Optional[Union[service.UpdateSecretRequest, dict]] = None, *, - secret: resources.Secret = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + secret: Optional[resources.Secret] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_update_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.UpdateSecretRequest( + ) + + # Make the request + response = await client.update_secret(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest, dict]]): The request object. Request message for [SecretManagerService.UpdateSecret][google.cloud.secrets.v1beta1.SecretManagerService.UpdateSecret]. secret (:class:`google.cloud.secretmanager_v1beta1.types.Secret`): @@ -597,7 +766,6 @@ async def update_secret( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -616,7 +784,7 @@ async def update_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([secret, update_mask]) if request is not None and has_flattened_params: @@ -629,7 +797,6 @@ async def update_secret( # If we have keyword arguments corresponding to fields on the # request, apply these. - if secret is not None: request.secret = secret if update_mask is not None: @@ -664,17 +831,40 @@ async def update_secret( async def delete_secret( self, - request: Union[service.DeleteSecretRequest, dict] = None, + request: Optional[Union[service.DeleteSecretRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_delete_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DeleteSecretRequest( + name="name_value", + ) + + # Make the request + await client.delete_secret(request=request) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest, dict]]): The request object. Request message for [SecretManagerService.DeleteSecret][google.cloud.secrets.v1beta1.SecretManagerService.DeleteSecret]. name (:class:`str`): @@ -685,7 +875,6 @@ async def delete_secret( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -693,7 +882,7 @@ async def delete_secret( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -706,7 +895,6 @@ async def delete_secret( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -734,19 +922,46 @@ async def delete_secret( async def list_secret_versions( self, - request: Union[service.ListSecretVersionsRequest, dict] = None, + request: Optional[Union[service.ListSecretVersionsRequest, dict]] = None, *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretVersionsAsyncPager: r"""Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_list_secret_versions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secret_versions(request=request) + + # Handle the response + async for response in page_result: + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest, dict]]): The request object. Request message for [SecretManagerService.ListSecretVersions][google.cloud.secrets.v1beta1.SecretManagerService.ListSecretVersions]. parent (:class:`str`): @@ -759,7 +974,6 @@ async def list_secret_versions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -776,7 +990,7 @@ async def list_secret_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -789,7 +1003,6 @@ async def list_secret_versions( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -829,11 +1042,11 @@ async def list_secret_versions( async def get_secret_version( self, - request: Union[service.GetSecretVersionRequest, dict] = None, + request: Optional[Union[service.GetSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a @@ -843,8 +1056,34 @@ async def get_secret_version( ``latest`` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_get_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.GetSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.GetSecretVersion]. name (:class:`str`): @@ -858,7 +1097,6 @@ async def get_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -872,7 +1110,7 @@ async def get_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -885,7 +1123,6 @@ async def get_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -916,11 +1153,11 @@ async def get_secret_version( async def access_secret_version( self, - request: Union[service.AccessSecretVersionRequest, dict] = None, + request: Optional[Union[service.AccessSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a @@ -931,8 +1168,34 @@ async def access_secret_version( ``latest`` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_access_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AccessSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.access_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.AccessSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.AccessSecretVersion]. name (:class:`str`): @@ -943,7 +1206,6 @@ async def access_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -957,7 +1219,7 @@ async def access_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -970,7 +1232,6 @@ async def access_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -983,8 +1244,8 @@ async def access_secret_version( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, - exceptions.Unknown, + core_exceptions.ServiceUnavailable, + core_exceptions.Unknown, ), deadline=60.0, ), @@ -1011,11 +1272,11 @@ async def access_secret_version( async def disable_secret_version( self, - request: Union[service.DisableSecretVersionRequest, dict] = None, + request: Optional[Union[service.DisableSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Disables a @@ -1026,8 +1287,34 @@ async def disable_secret_version( [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_disable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DisableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.disable_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.DisableSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.DisableSecretVersion]. name (:class:`str`): @@ -1039,7 +1326,6 @@ async def disable_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1053,7 +1339,7 @@ async def disable_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1066,7 +1352,6 @@ async def disable_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1097,11 +1382,11 @@ async def disable_secret_version( async def enable_secret_version( self, - request: Union[service.EnableSecretVersionRequest, dict] = None, + request: Optional[Union[service.EnableSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Enables a @@ -1112,8 +1397,34 @@ async def enable_secret_version( [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_enable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.EnableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.enable_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.EnableSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.EnableSecretVersion]. name (:class:`str`): @@ -1125,7 +1436,6 @@ async def enable_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1139,7 +1449,7 @@ async def enable_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1152,7 +1462,6 @@ async def enable_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1183,11 +1492,11 @@ async def enable_secret_version( async def destroy_secret_version( self, - request: Union[service.DestroySecretVersionRequest, dict] = None, + request: Optional[Union[service.DestroySecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Destroys a @@ -1199,8 +1508,34 @@ async def destroy_secret_version( [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + async def sample_destroy_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DestroySecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.destroy_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest, dict]): + request (Optional[Union[google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest, dict]]): The request object. Request message for [SecretManagerService.DestroySecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.DestroySecretVersion]. name (:class:`str`): @@ -1212,7 +1547,6 @@ async def destroy_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1226,7 +1560,7 @@ async def destroy_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1239,7 +1573,6 @@ async def destroy_secret_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1270,12 +1603,12 @@ async def destroy_secret_version( async def set_iam_policy( self, - request: Union[iam_policy.SetIamPolicyRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -1284,11 +1617,37 @@ async def set_iam_policy( enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_set_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): + request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): The request object. Request message for `SetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1297,21 +1656,26 @@ async def set_iam_policy( Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1326,17 +1690,17 @@ async def set_iam_policy( }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1347,19 +1711,19 @@ async def set_iam_policy( condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.SetIamPolicyRequest(**request) + request = iam_policy_pb2.SetIamPolicyRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1388,21 +1752,47 @@ async def set_iam_policy( async def get_iam_policy( self, - request: Union[iam_policy.GetIamPolicyRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_get_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): + request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): The request object. Request message for `GetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1411,21 +1801,26 @@ async def get_iam_policy( Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1440,17 +1835,17 @@ async def get_iam_policy( }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1461,19 +1856,19 @@ async def get_iam_policy( condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.GetIamPolicyRequest(**request) + request = iam_policy_pb2.GetIamPolicyRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1502,12 +1897,12 @@ async def get_iam_policy( async def test_iam_permissions( self, - request: Union[iam_policy.TestIamPermissionsRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy.TestIamPermissionsResponse: + ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. @@ -1517,11 +1912,38 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_test_iam_permissions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: - request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): + request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): The request object. Request message for `TestIamPermissions` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1533,11 +1955,10 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.TestIamPermissionsRequest(**request) + request = iam_policy_pb2.TestIamPermissionsRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1564,15 +1985,16 @@ async def test_iam_permissions( # Done; return the response. return response + async def __aenter__(self): + return self -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("SecretManagerServiceAsyncClient",) diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py index 0d46a48..c07f8e2 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,27 +13,43 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict -from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -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.oauth2 import service_account # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -import pkg_resources + +from google.cloud.secretmanager_v1beta1 import gapic_version as package_version + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.secretmanager_v1beta1.services.secret_manager_service import pagers from google.cloud.secretmanager_v1beta1.types import resources, service @@ -60,9 +75,9 @@ class SecretManagerServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[SecretManagerServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -92,7 +107,8 @@ class SecretManagerServiceClient(metaclass=SecretManagerServiceClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -126,7 +142,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -143,7 +160,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -162,10 +179,11 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> SecretManagerServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - SecretManagerServiceTransport: The transport used by the client instance. + SecretManagerServiceTransport: The transport used by the client + instance. """ return self._transport @@ -174,7 +192,7 @@ def secret_path( project: str, secret: str, ) -> str: - """Return a fully-qualified secret string.""" + """Returns a fully-qualified secret string.""" return "projects/{project}/secrets/{secret}".format( project=project, secret=secret, @@ -182,7 +200,7 @@ def secret_path( @staticmethod def parse_secret_path(path: str) -> Dict[str, str]: - """Parse a secret path into its component segments.""" + """Parses a secret path into its component segments.""" m = re.match(r"^projects/(?P.+?)/secrets/(?P.+?)$", path) return m.groupdict() if m else {} @@ -192,7 +210,7 @@ def secret_version_path( secret: str, secret_version: str, ) -> str: - """Return a fully-qualified secret_version string.""" + """Returns a fully-qualified secret_version string.""" return "projects/{project}/secrets/{secret}/versions/{secret_version}".format( project=project, secret=secret, @@ -201,7 +219,7 @@ def secret_version_path( @staticmethod def parse_secret_version_path(path: str) -> Dict[str, str]: - """Parse a secret_version path into its component segments.""" + """Parses a secret_version path into its component segments.""" m = re.match( r"^projects/(?P.+?)/secrets/(?P.+?)/versions/(?P.+?)$", path, @@ -212,7 +230,7 @@ def parse_secret_version_path(path: str) -> Dict[str, str]: def common_billing_account_path( billing_account: str, ) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -227,7 +245,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: def common_folder_path( folder: str, ) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format( folder=folder, ) @@ -242,7 +260,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: def common_organization_path( organization: str, ) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format( organization=organization, ) @@ -257,7 +275,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: def common_project_path( project: str, ) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format( project=project, ) @@ -273,7 +291,7 @@ def common_location_path( project: str, location: str, ) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, @@ -285,15 +303,82 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, - transport: Union[str, SecretManagerServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, SecretManagerServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the secret manager service client. + """Instantiates the secret manager service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -304,7 +389,7 @@ def __init__( transport (Union[str, SecretManagerServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -334,59 +419,44 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SecretManagerServiceTransport): # transport is a SecretManagerServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -396,21 +466,50 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def list_secrets( self, - request: Union[service.ListSecretsRequest, dict] = None, + request: Optional[Union[service.ListSecretsRequest, dict]] = None, *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretsPager: r"""Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_list_secrets(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secrets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.ListSecretsRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.ListSecretsRequest, dict]): The request object. Request message for [SecretManagerService.ListSecrets][google.cloud.secrets.v1beta1.SecretManagerService.ListSecrets]. parent (str): @@ -421,7 +520,6 @@ def list_secrets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -438,7 +536,7 @@ def list_secrets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -453,10 +551,8 @@ def list_secrets( # there are no flattened fields. if not isinstance(request, service.ListSecretsRequest): request = service.ListSecretsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -492,21 +588,48 @@ def list_secrets( def create_secret( self, - request: Union[service.CreateSecretRequest, dict] = None, + request: Optional[Union[service.CreateSecretRequest, dict]] = None, *, - parent: str = None, - secret_id: str = None, - secret: resources.Secret = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + secret_id: Optional[str] = None, + secret: Optional[resources.Secret] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_create_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.CreateSecretRequest( + parent="parent_value", + secret_id="secret_id_value", + ) + + # Make the request + response = client.create_secret(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.CreateSecretRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.CreateSecretRequest, dict]): The request object. Request message for [SecretManagerService.CreateSecret][google.cloud.secrets.v1beta1.SecretManagerService.CreateSecret]. parent (str): @@ -536,7 +659,6 @@ def create_secret( This corresponds to the ``secret`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -555,7 +677,7 @@ def create_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, secret_id, secret]) if request is not None and has_flattened_params: @@ -570,10 +692,8 @@ def create_secret( # there are no flattened fields. if not isinstance(request, service.CreateSecretRequest): request = service.CreateSecretRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if secret_id is not None: @@ -604,12 +724,12 @@ def create_secret( def add_secret_version( self, - request: Union[service.AddSecretVersionRequest, dict] = None, + request: Optional[Union[service.AddSecretVersionRequest, dict]] = None, *, - parent: str = None, - payload: resources.SecretPayload = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + payload: Optional[resources.SecretPayload] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Creates a new @@ -617,8 +737,34 @@ def add_secret_version( containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_add_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AddSecretVersionRequest( + parent="parent_value", + ) + + # Make the request + response = client.add_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.AddSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.AddSecretVersion]. parent (str): @@ -638,7 +784,6 @@ def add_secret_version( This corresponds to the ``payload`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -652,7 +797,7 @@ def add_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, payload]) if request is not None and has_flattened_params: @@ -667,10 +812,8 @@ def add_secret_version( # there are no flattened fields. if not isinstance(request, service.AddSecretVersionRequest): request = service.AddSecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if payload is not None: @@ -699,18 +842,44 @@ def add_secret_version( def get_secret( self, - request: Union[service.GetSecretRequest, dict] = None, + request: Optional[Union[service.GetSecretRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_get_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretRequest( + name="name_value", + ) + + # Make the request + response = client.get_secret(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.GetSecretRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.GetSecretRequest, dict]): The request object. Request message for [SecretManagerService.GetSecret][google.cloud.secrets.v1beta1.SecretManagerService.GetSecret]. name (str): @@ -721,7 +890,6 @@ def get_secret( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -740,7 +908,7 @@ def get_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -755,10 +923,8 @@ def get_secret( # there are no flattened fields. if not isinstance(request, service.GetSecretRequest): request = service.GetSecretRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -785,19 +951,44 @@ def get_secret( def update_secret( self, - request: service.UpdateSecretRequest = None, + request: Optional[Union[service.UpdateSecretRequest, dict]] = None, *, - secret: resources.Secret = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + secret: Optional[resources.Secret] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_update_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.UpdateSecretRequest( + ) + + # Make the request + response = client.update_secret(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest, dict]): The request object. Request message for [SecretManagerService.UpdateSecret][google.cloud.secrets.v1beta1.SecretManagerService.UpdateSecret]. secret (google.cloud.secretmanager_v1beta1.types.Secret): @@ -814,7 +1005,6 @@ def update_secret( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -833,7 +1023,7 @@ def update_secret( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([secret, update_mask]) if request is not None and has_flattened_params: @@ -848,10 +1038,8 @@ def update_secret( # there are no flattened fields. if not isinstance(request, service.UpdateSecretRequest): request = service.UpdateSecretRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if secret is not None: request.secret = secret if update_mask is not None: @@ -882,17 +1070,40 @@ def update_secret( def delete_secret( self, - request: Union[service.DeleteSecretRequest, dict] = None, + request: Optional[Union[service.DeleteSecretRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_delete_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DeleteSecretRequest( + name="name_value", + ) + + # Make the request + client.delete_secret(request=request) + Args: - request (google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest, dict]): The request object. Request message for [SecretManagerService.DeleteSecret][google.cloud.secrets.v1beta1.SecretManagerService.DeleteSecret]. name (str): @@ -903,7 +1114,6 @@ def delete_secret( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -911,7 +1121,7 @@ def delete_secret( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -926,10 +1136,8 @@ def delete_secret( # there are no flattened fields. if not isinstance(request, service.DeleteSecretRequest): request = service.DeleteSecretRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -953,19 +1161,46 @@ def delete_secret( def list_secret_versions( self, - request: Union[service.ListSecretVersionsRequest, dict] = None, + request: Optional[Union[service.ListSecretVersionsRequest, dict]] = None, *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSecretVersionsPager: r"""Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_list_secret_versions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secret_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest, dict]): The request object. Request message for [SecretManagerService.ListSecretVersions][google.cloud.secrets.v1beta1.SecretManagerService.ListSecretVersions]. parent (str): @@ -978,7 +1213,6 @@ def list_secret_versions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -995,7 +1229,7 @@ def list_secret_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1010,10 +1244,8 @@ def list_secret_versions( # there are no flattened fields. if not isinstance(request, service.ListSecretVersionsRequest): request = service.ListSecretVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1049,11 +1281,11 @@ def list_secret_versions( def get_secret_version( self, - request: Union[service.GetSecretVersionRequest, dict] = None, + request: Optional[Union[service.GetSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a @@ -1063,8 +1295,34 @@ def get_secret_version( ``latest`` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_get_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.GetSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.GetSecretVersion]. name (str): @@ -1078,7 +1336,6 @@ def get_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1092,7 +1349,7 @@ def get_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1107,10 +1364,8 @@ def get_secret_version( # there are no flattened fields. if not isinstance(request, service.GetSecretVersionRequest): request = service.GetSecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1137,11 +1392,11 @@ def get_secret_version( def access_secret_version( self, - request: Union[service.AccessSecretVersionRequest, dict] = None, + request: Optional[Union[service.AccessSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a @@ -1152,8 +1407,34 @@ def access_secret_version( ``latest`` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_access_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AccessSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.access_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.AccessSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.AccessSecretVersion]. name (str): @@ -1164,7 +1445,6 @@ def access_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1178,7 +1458,7 @@ def access_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1193,10 +1473,8 @@ def access_secret_version( # there are no flattened fields. if not isinstance(request, service.AccessSecretVersionRequest): request = service.AccessSecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1223,11 +1501,11 @@ def access_secret_version( def disable_secret_version( self, - request: Union[service.DisableSecretVersionRequest, dict] = None, + request: Optional[Union[service.DisableSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Disables a @@ -1238,8 +1516,34 @@ def disable_secret_version( [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_disable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DisableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.disable_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.DisableSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.DisableSecretVersion]. name (str): @@ -1251,7 +1555,6 @@ def disable_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1265,7 +1568,7 @@ def disable_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1280,10 +1583,8 @@ def disable_secret_version( # there are no flattened fields. if not isinstance(request, service.DisableSecretVersionRequest): request = service.DisableSecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1310,11 +1611,11 @@ def disable_secret_version( def enable_secret_version( self, - request: Union[service.EnableSecretVersionRequest, dict] = None, + request: Optional[Union[service.EnableSecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Enables a @@ -1325,8 +1626,34 @@ def enable_secret_version( [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_enable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.EnableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.enable_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.EnableSecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.EnableSecretVersion]. name (str): @@ -1338,7 +1665,6 @@ def enable_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1352,7 +1678,7 @@ def enable_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1367,10 +1693,8 @@ def enable_secret_version( # there are no flattened fields. if not isinstance(request, service.EnableSecretVersionRequest): request = service.EnableSecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1397,11 +1721,11 @@ def enable_secret_version( def destroy_secret_version( self, - request: Union[service.DestroySecretVersionRequest, dict] = None, + request: Optional[Union[service.DestroySecretVersionRequest, dict]] = None, *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.SecretVersion: r"""Destroys a @@ -1413,8 +1737,34 @@ def destroy_secret_version( [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + + def sample_destroy_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DestroySecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.destroy_secret_version(request=request) + + # Handle the response + print(response) + Args: - request (google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest): + request (Union[google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest, dict]): The request object. Request message for [SecretManagerService.DestroySecretVersion][google.cloud.secrets.v1beta1.SecretManagerService.DestroySecretVersion]. name (str): @@ -1426,7 +1776,6 @@ def destroy_secret_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1440,7 +1789,7 @@ def destroy_secret_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1455,10 +1804,8 @@ def destroy_secret_version( # there are no flattened fields. if not isinstance(request, service.DestroySecretVersionRequest): request = service.DestroySecretVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1485,12 +1832,12 @@ def destroy_secret_version( def set_iam_policy( self, - request: Union[iam_policy.SetIamPolicyRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -1499,11 +1846,37 @@ def set_iam_policy( enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret]. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_set_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: - request (google.iam.v1.iam_policy_pb2.SetIamPolicyRequest): + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1512,21 +1885,26 @@ def set_iam_policy( Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1541,17 +1919,17 @@ def set_iam_policy( }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1562,22 +1940,22 @@ def set_iam_policy( condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.SetIamPolicyRequest(**request) + request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.SetIamPolicyRequest() + request = iam_policy_pb2.SetIamPolicyRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1602,21 +1980,47 @@ def set_iam_policy( def get_iam_policy( self, - request: Union[iam_policy.GetIamPolicyRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_get_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: - request (google.iam.v1.iam_policy_pb2.GetIamPolicyRequest): + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1625,21 +2029,26 @@ def get_iam_policy( Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1654,17 +2063,17 @@ def get_iam_policy( }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1675,22 +2084,22 @@ def get_iam_policy( condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.GetIamPolicyRequest(**request) + request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.GetIamPolicyRequest() + request = iam_policy_pb2.GetIamPolicyRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1715,12 +2124,12 @@ def get_iam_policy( def test_iam_permissions( self, - request: Union[iam_policy.TestIamPermissionsRequest, dict] = None, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy.TestIamPermissionsResponse: + ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. @@ -1730,11 +2139,38 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import secretmanager_v1beta1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_test_iam_permissions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: - request (google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest): + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for `TestIamPermissions` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1746,14 +2182,13 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.TestIamPermissionsRequest(**request) + request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.TestIamPermissionsRequest() + request = iam_policy_pb2.TestIamPermissionsRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1776,15 +2211,23 @@ def test_iam_permissions( # Done; return the response. return response + def __enter__(self): + return self -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("SecretManagerServiceClient",) diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py index 7288301..15d03d3 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, - AsyncIterable, + AsyncIterator, Awaitable, Callable, - Iterable, + Iterator, Optional, Sequence, Tuple, @@ -76,14 +74,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - def pages(self) -> Iterable[service.ListSecretsResponse]: + def pages(self) -> Iterator[service.ListSecretsResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterable[resources.Secret]: + def __iter__(self) -> Iterator[resources.Secret]: for page in self.pages: yield from page.secrets @@ -117,7 +115,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -138,14 +136,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - async def pages(self) -> AsyncIterable[service.ListSecretsResponse]: + async def pages(self) -> AsyncIterator[service.ListSecretsResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterable[resources.Secret]: + def __aiter__(self) -> AsyncIterator[resources.Secret]: async def async_generator(): async for page in self.pages: for response in page.secrets: @@ -204,14 +202,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - def pages(self) -> Iterable[service.ListSecretVersionsResponse]: + def pages(self) -> Iterator[service.ListSecretVersionsResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterable[resources.SecretVersion]: + def __iter__(self) -> Iterator[resources.SecretVersion]: for page in self.pages: yield from page.versions @@ -245,7 +243,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -266,14 +264,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - async def pages(self) -> AsyncIterable[service.ListSecretVersionsResponse]: + async def pages(self) -> AsyncIterator[service.ListSecretVersionsResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterable[resources.SecretVersion]: + def __aiter__(self) -> AsyncIterator[resources.SecretVersion]: async def async_generator(): async for page in self.pages: for response in page.versions: diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/__init__.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/__init__.py index d2cc7d0..d997f77 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/__init__.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py index 0f584f2..ff78451 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,30 +13,26 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing - -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore -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 empty_pb2 as empty # type: ignore -import pkg_resources - -from google import auth # type: ignore +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union + +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.oauth2 import service_account # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +from google.cloud.secretmanager_v1beta1 import gapic_version as package_version from google.cloud.secretmanager_v1beta1.types import resources, service -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-secret-manager", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class SecretManagerServiceTransport(abc.ABC): @@ -45,21 +40,26 @@ class SecretManagerServiceTransport(abc.ABC): AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "secretmanager.googleapis.com" + def __init__( self, *, - host: str = "secretmanager.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -68,7 +68,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -76,35 +76,52 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host + + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -155,8 +172,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, - exceptions.Unknown, + core_exceptions.ServiceUnavailable, + core_exceptions.Unknown, ), deadline=60.0, ), @@ -195,72 +212,76 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_secrets( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListSecretsRequest], - typing.Union[ - service.ListSecretsResponse, typing.Awaitable[service.ListSecretsResponse] - ], + Union[service.ListSecretsResponse, Awaitable[service.ListSecretsResponse]], ]: raise NotImplementedError() @property def create_secret( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateSecretRequest], - typing.Union[resources.Secret, typing.Awaitable[resources.Secret]], + Union[resources.Secret, Awaitable[resources.Secret]], ]: raise NotImplementedError() @property def add_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.AddSecretVersionRequest], - typing.Union[ - resources.SecretVersion, typing.Awaitable[resources.SecretVersion] - ], + Union[resources.SecretVersion, Awaitable[resources.SecretVersion]], ]: raise NotImplementedError() @property def get_secret( self, - ) -> typing.Callable[ - [service.GetSecretRequest], - typing.Union[resources.Secret, typing.Awaitable[resources.Secret]], + ) -> Callable[ + [service.GetSecretRequest], Union[resources.Secret, Awaitable[resources.Secret]] ]: raise NotImplementedError() @property def update_secret( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateSecretRequest], - typing.Union[resources.Secret, typing.Awaitable[resources.Secret]], + Union[resources.Secret, Awaitable[resources.Secret]], ]: raise NotImplementedError() @property def delete_secret( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DeleteSecretRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def list_secret_versions( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListSecretVersionsRequest], - typing.Union[ + Union[ service.ListSecretVersionsResponse, - typing.Awaitable[service.ListSecretVersionsResponse], + Awaitable[service.ListSecretVersionsResponse], ], ]: raise NotImplementedError() @@ -268,22 +289,20 @@ def list_secret_versions( @property def get_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetSecretVersionRequest], - typing.Union[ - resources.SecretVersion, typing.Awaitable[resources.SecretVersion] - ], + Union[resources.SecretVersion, Awaitable[resources.SecretVersion]], ]: raise NotImplementedError() @property def access_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.AccessSecretVersionRequest], - typing.Union[ + Union[ service.AccessSecretVersionResponse, - typing.Awaitable[service.AccessSecretVersionResponse], + Awaitable[service.AccessSecretVersionResponse], ], ]: raise NotImplementedError() @@ -291,65 +310,63 @@ def access_secret_version( @property def disable_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DisableSecretVersionRequest], - typing.Union[ - resources.SecretVersion, typing.Awaitable[resources.SecretVersion] - ], + Union[resources.SecretVersion, Awaitable[resources.SecretVersion]], ]: raise NotImplementedError() @property def enable_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.EnableSecretVersionRequest], - typing.Union[ - resources.SecretVersion, typing.Awaitable[resources.SecretVersion] - ], + Union[resources.SecretVersion, Awaitable[resources.SecretVersion]], ]: raise NotImplementedError() @property def destroy_secret_version( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DestroySecretVersionRequest], - typing.Union[ - resources.SecretVersion, typing.Awaitable[resources.SecretVersion] - ], + Union[resources.SecretVersion, Awaitable[resources.SecretVersion]], ]: raise NotImplementedError() @property def set_iam_policy( self, - ) -> typing.Callable[ - [iam_policy.SetIamPolicyRequest], - typing.Union[policy.Policy, typing.Awaitable[policy.Policy]], + ) -> Callable[ + [iam_policy_pb2.SetIamPolicyRequest], + Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError() @property def get_iam_policy( self, - ) -> typing.Callable[ - [iam_policy.GetIamPolicyRequest], - typing.Union[policy.Policy, typing.Awaitable[policy.Policy]], + ) -> Callable[ + [iam_policy_pb2.GetIamPolicyRequest], + Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError() @property def test_iam_permissions( self, - ) -> typing.Callable[ - [iam_policy.TestIamPermissionsRequest], - typing.Union[ - iam_policy.TestIamPermissionsResponse, - typing.Awaitable[iam_policy.TestIamPermissionsResponse], + ) -> Callable[ + [iam_policy_pb2.TestIamPermissionsRequest], + Union[ + iam_policy_pb2.TestIamPermissionsResponse, + Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("SecretManagerServiceTransport",) diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py index 9956ce6..62fa621 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,20 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers # type: ignore -from google.auth import credentials # type: ignore +from google.api_core import gapic_v1, grpc_helpers +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -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 empty_pb2 as empty # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore -from google import auth # type: ignore from google.cloud.secretmanager_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport @@ -58,21 +55,24 @@ def __init__( self, *, host: str = "secretmanager.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -95,10 +95,10 @@ def __init__( private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. @@ -107,6 +107,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -159,13 +161,18 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -182,8 +189,8 @@ def __init__( def create_channel( cls, host: str = "secretmanager.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, @@ -213,13 +220,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) @@ -364,7 +373,7 @@ def update_secret( return self._stubs["update_secret"] @property - def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty.Empty]: + def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty_pb2.Empty]: r"""Return a callable for the delete secret method over gRPC. Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -383,7 +392,7 @@ def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty.Empty]: self._stubs["delete_secret"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_secret"] @@ -582,7 +591,7 @@ def destroy_secret_version( @property def set_iam_policy( self, - ) -> Callable[[iam_policy.SetIamPolicyRequest], policy.Policy]: + ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the access control policy on the specified secret. Replaces @@ -606,15 +615,15 @@ def set_iam_policy( if "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy", - request_serializer=iam_policy.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"] @property def get_iam_policy( self, - ) -> Callable[[iam_policy.GetIamPolicyRequest], policy.Policy]: + ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the access control policy for a secret. @@ -634,8 +643,8 @@ def get_iam_policy( if "get_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy", - request_serializer=iam_policy.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"] @@ -643,7 +652,8 @@ def get_iam_policy( def test_iam_permissions( self, ) -> Callable[ - [iam_policy.TestIamPermissionsRequest], iam_policy.TestIamPermissionsResponse + [iam_policy_pb2.TestIamPermissionsRequest], + iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. @@ -669,10 +679,17 @@ def test_iam_permissions( if "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions", - request_serializer=iam_policy.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy.TestIamPermissionsResponse.FromString, + request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, + response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"] + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + __all__ = ("SecretManagerServiceGrpcTransport",) diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py index 5f83a53..b8a92d7 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,21 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.auth import credentials # type: ignore +from google.api_core import gapic_v1, grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -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 empty_pb2 as empty # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore -from google import auth # type: ignore from google.cloud.secretmanager_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport @@ -61,7 +57,7 @@ class SecretManagerServiceGrpcAsyncIOTransport(SecretManagerServiceTransport): def create_channel( cls, host: str = "secretmanager.googleapis.com", - credentials: credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -88,13 +84,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) @@ -102,21 +100,24 @@ def __init__( self, *, host: str = "secretmanager.googleapis.com", - credentials: credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -140,10 +141,10 @@ def __init__( private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. @@ -152,6 +153,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -174,7 +177,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -204,13 +206,18 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -375,7 +382,7 @@ def update_secret( @property def delete_secret( self, - ) -> Callable[[service.DeleteSecretRequest], Awaitable[empty.Empty]]: + ) -> Callable[[service.DeleteSecretRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete secret method over gRPC. Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -394,7 +401,7 @@ def delete_secret( self._stubs["delete_secret"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_secret"] @@ -603,7 +610,7 @@ def destroy_secret_version( @property def set_iam_policy( self, - ) -> Callable[[iam_policy.SetIamPolicyRequest], Awaitable[policy.Policy]]: + ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the set iam policy method over gRPC. Sets the access control policy on the specified secret. Replaces @@ -627,15 +634,15 @@ def set_iam_policy( if "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy", - request_serializer=iam_policy.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"] @property def get_iam_policy( self, - ) -> Callable[[iam_policy.GetIamPolicyRequest], Awaitable[policy.Policy]]: + ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the get iam policy method over gRPC. Gets the access control policy for a secret. @@ -655,8 +662,8 @@ def get_iam_policy( if "get_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy", - request_serializer=iam_policy.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"] @@ -664,8 +671,8 @@ def get_iam_policy( def test_iam_permissions( self, ) -> Callable[ - [iam_policy.TestIamPermissionsRequest], - Awaitable[iam_policy.TestIamPermissionsResponse], + [iam_policy_pb2.TestIamPermissionsRequest], + Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ]: r"""Return a callable for the test iam permissions method over gRPC. @@ -691,10 +698,13 @@ def test_iam_permissions( if "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions", - request_serializer=iam_policy.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy.TestIamPermissionsResponse.FromString, + request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, + response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"] + def close(self): + return self.grpc_channel.close() + __all__ = ("SecretManagerServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/secretmanager_v1beta1/types/__init__.py b/google/cloud/secretmanager_v1beta1/types/__init__.py index 28dcf21..f657c74 100644 --- a/google/cloud/secretmanager_v1beta1/types/__init__.py +++ b/google/cloud/secretmanager_v1beta1/types/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .resources import Replication, Secret, SecretPayload, SecretVersion from .service import ( AccessSecretVersionRequest, diff --git a/google/cloud/secretmanager_v1beta1/types/resources.py b/google/cloud/secretmanager_v1beta1/types/resources.py index e0998e1..a7afbe8 100644 --- a/google/cloud/secretmanager_v1beta1/types/resources.py +++ b/google/cloud/secretmanager_v1beta1/types/resources.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore __protobuf__ = proto.module( @@ -52,7 +52,7 @@ class Secret(proto.Message): create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time at which the [Secret][google.cloud.secrets.v1beta1.Secret] was created. - labels (Sequence[google.cloud.secretmanager_v1beta1.types.Secret.LabelsEntry]): + labels (MutableMapping[str, str]): The labels assigned to this Secret. Label keys must be between 1 and 63 characters long, have a @@ -68,21 +68,25 @@ class Secret(proto.Message): No more than 64 labels can be assigned to a given resource. """ - name = proto.Field(proto.STRING, number=1) - - replication = proto.Field( + name: str = proto.Field( + proto.STRING, + number=1, + ) + replication: "Replication" = proto.Field( proto.MESSAGE, number=2, message="Replication", ) - - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=3, - message=timestamp.Timestamp, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, ) - - labels = proto.MapField(proto.STRING, proto.STRING, number=4) class SecretVersion(proto.Message): @@ -123,21 +127,21 @@ class State(proto.Enum): DISABLED = 2 DESTROYED = 3 - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field( + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, - message=timestamp.Timestamp, + message=timestamp_pb2.Timestamp, ) - - destroy_time = proto.Field( + destroy_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=3, - message=timestamp.Timestamp, + message=timestamp_pb2.Timestamp, ) - - state = proto.Field( + state: State = proto.Field( proto.ENUM, number=4, enum=State, @@ -147,19 +151,31 @@ class State(proto.Enum): class Replication(proto.Message): r"""A policy that defines the replication configuration of data. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: automatic (google.cloud.secretmanager_v1beta1.types.Replication.Automatic): The [Secret][google.cloud.secrets.v1beta1.Secret] will automatically be replicated without any restrictions. + + This field is a member of `oneof`_ ``replication``. user_managed (google.cloud.secretmanager_v1beta1.types.Replication.UserManaged): The [Secret][google.cloud.secrets.v1beta1.Secret] will only be replicated into the locations specified. + + This field is a member of `oneof`_ ``replication``. """ class Automatic(proto.Message): r"""A replication policy that replicates the [Secret][google.cloud.secrets.v1beta1.Secret] payload without any restrictions. + """ class UserManaged(proto.Message): @@ -168,7 +184,7 @@ class UserManaged(proto.Message): locations specified in [Secret.replication.user_managed.replicas][] Attributes: - replicas (Sequence[google.cloud.secretmanager_v1beta1.types.Replication.UserManaged.Replica]): + replicas (MutableSequence[google.cloud.secretmanager_v1beta1.types.Replication.UserManaged.Replica]): Required. The list of Replicas for this [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -185,22 +201,26 @@ class Replica(proto.Message): example: ``"us-east1"``. """ - location = proto.Field(proto.STRING, number=1) + location: str = proto.Field( + proto.STRING, + number=1, + ) - replicas = proto.RepeatedField( + replicas: MutableSequence[ + "Replication.UserManaged.Replica" + ] = proto.RepeatedField( proto.MESSAGE, number=1, message="Replication.UserManaged.Replica", ) - automatic = proto.Field( + automatic: Automatic = proto.Field( proto.MESSAGE, number=1, oneof="replication", message=Automatic, ) - - user_managed = proto.Field( + user_managed: UserManaged = proto.Field( proto.MESSAGE, number=2, oneof="replication", @@ -219,7 +239,10 @@ class SecretPayload(proto.Message): 64KiB. """ - data = proto.Field(proto.BYTES, number=1) + data: bytes = proto.Field( + proto.BYTES, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/secretmanager_v1beta1/types/service.py b/google/cloud/secretmanager_v1beta1/types/service.py index 43465aa..01bb9aa 100644 --- a/google/cloud/secretmanager_v1beta1/types/service.py +++ b/google/cloud/secretmanager_v1beta1/types/service.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore from google.cloud.secretmanager_v1beta1.types import resources @@ -62,11 +62,18 @@ class ListSecretsRequest(proto.Message): [ListSecretsResponse.next_page_token][google.cloud.secrets.v1beta1.ListSecretsResponse.next_page_token]. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) class ListSecretsResponse(proto.Message): @@ -74,7 +81,7 @@ class ListSecretsResponse(proto.Message): [SecretManagerService.ListSecrets][google.cloud.secrets.v1beta1.SecretManagerService.ListSecrets]. Attributes: - secrets (Sequence[google.cloud.secretmanager_v1beta1.types.Secret]): + secrets (MutableSequence[google.cloud.secretmanager_v1beta1.types.Secret]): The list of [Secrets][google.cloud.secrets.v1beta1.Secret] sorted in reverse by create_time (newest first). next_page_token (str): @@ -91,15 +98,19 @@ class ListSecretsResponse(proto.Message): def raw_page(self): return self - secrets = proto.RepeatedField( + secrets: MutableSequence[resources.Secret] = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.Secret, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - total_size = proto.Field(proto.INT32, number=3) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + total_size: int = proto.Field( + proto.INT32, + number=3, + ) class CreateSecretRequest(proto.Message): @@ -123,11 +134,15 @@ class CreateSecretRequest(proto.Message): with initial field values. """ - parent = proto.Field(proto.STRING, number=1) - - secret_id = proto.Field(proto.STRING, number=2) - - secret = proto.Field( + parent: str = proto.Field( + proto.STRING, + number=1, + ) + secret_id: str = proto.Field( + proto.STRING, + number=2, + ) + secret: resources.Secret = proto.Field( proto.MESSAGE, number=3, message=resources.Secret, @@ -150,9 +165,11 @@ class AddSecretVersionRequest(proto.Message): [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. """ - parent = proto.Field(proto.STRING, number=1) - - payload = proto.Field( + parent: str = proto.Field( + proto.STRING, + number=1, + ) + payload: resources.SecretPayload = proto.Field( proto.MESSAGE, number=2, message=resources.SecretPayload, @@ -170,7 +187,10 @@ class GetSecretRequest(proto.Message): ``projects/*/secrets/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class ListSecretVersionsRequest(proto.Message): @@ -195,11 +215,18 @@ class ListSecretVersionsRequest(proto.Message): ListSecretVersionsResponse.next_page_token][]. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) class ListSecretVersionsResponse(proto.Message): @@ -207,7 +234,7 @@ class ListSecretVersionsResponse(proto.Message): [SecretManagerService.ListSecretVersions][google.cloud.secrets.v1beta1.SecretManagerService.ListSecretVersions]. Attributes: - versions (Sequence[google.cloud.secretmanager_v1beta1.types.SecretVersion]): + versions (MutableSequence[google.cloud.secretmanager_v1beta1.types.SecretVersion]): The list of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] sorted in reverse by create_time (newest first). @@ -225,15 +252,19 @@ class ListSecretVersionsResponse(proto.Message): def raw_page(self): return self - versions = proto.RepeatedField( + versions: MutableSequence[resources.SecretVersion] = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.SecretVersion, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - total_size = proto.Field(proto.INT32, number=3) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + total_size: int = proto.Field( + proto.INT32, + number=3, + ) class GetSecretVersionRequest(proto.Message): @@ -250,7 +281,10 @@ class GetSecretVersionRequest(proto.Message): [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class UpdateSecretRequest(proto.Message): @@ -265,16 +299,15 @@ class UpdateSecretRequest(proto.Message): Required. Specifies the fields to be updated. """ - secret = proto.Field( + secret: resources.Secret = proto.Field( proto.MESSAGE, number=1, message=resources.Secret, ) - - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, - message=field_mask.FieldMask, + message=field_mask_pb2.FieldMask, ) @@ -289,7 +322,10 @@ class AccessSecretVersionRequest(proto.Message): in the format ``projects/*/secrets/*/versions/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class AccessSecretVersionResponse(proto.Message): @@ -305,9 +341,11 @@ class AccessSecretVersionResponse(proto.Message): Secret payload """ - name = proto.Field(proto.STRING, number=1) - - payload = proto.Field( + name: str = proto.Field( + proto.STRING, + number=1, + ) + payload: resources.SecretPayload = proto.Field( proto.MESSAGE, number=2, message=resources.SecretPayload, @@ -325,7 +363,10 @@ class DeleteSecretRequest(proto.Message): the format ``projects/*/secrets/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class DisableSecretVersionRequest(proto.Message): @@ -340,7 +381,10 @@ class DisableSecretVersionRequest(proto.Message): ``projects/*/secrets/*/versions/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class EnableSecretVersionRequest(proto.Message): @@ -354,7 +398,10 @@ class EnableSecretVersionRequest(proto.Message): to enable in the format ``projects/*/secrets/*/versions/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) class DestroySecretVersionRequest(proto.Message): @@ -369,7 +416,10 @@ class DestroySecretVersionRequest(proto.Message): ``projects/*/secrets/*/versions/*``. """ - name = proto.Field(proto.STRING, number=1) + name: str = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/release-please-config.json b/release-please-config.json index d8b8c27..4b0a837 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,6 +4,8 @@ ".": { "release-type": "python", "extra-files": [ + "google/cloud/secretmanager_v1/gapic_version.py", + "google/cloud/secretmanager_v1beta1/gapic_version.py", "google/cloud/secretmanager/gapic_version.py", { "type": "json", diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_async.py new file mode 100644 index 0000000..d599ed7 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AccessSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_access_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AccessSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.access_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_sync.py new file mode 100644 index 0000000..af8c1d0 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AccessSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_access_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AccessSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.access_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_async.py new file mode 100644 index 0000000..7a5a7f1 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AddSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_add_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AddSecretVersionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.add_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_sync.py new file mode 100644 index 0000000..346450a --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AddSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_add_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.AddSecretVersionRequest( + parent="parent_value", + ) + + # Make the request + response = client.add_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_async.py new file mode 100644 index 0000000..bbec067 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_create_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.CreateSecretRequest( + parent="parent_value", + secret_id="secret_id_value", + ) + + # Make the request + response = await client.create_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_sync.py new file mode 100644 index 0000000..4586bd3 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_create_secret_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_create_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.CreateSecretRequest( + parent="parent_value", + secret_id="secret_id_value", + ) + + # Make the request + response = client.create_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_async.py new file mode 100644 index 0000000..a62fe1a --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_delete_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DeleteSecretRequest( + name="name_value", + ) + + # Make the request + await client.delete_secret(request=request) + + +# [END secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_sync.py new file mode 100644 index 0000000..0b0f7c7 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_delete_secret_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_delete_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DeleteSecretRequest( + name="name_value", + ) + + # Make the request + client.delete_secret(request=request) + + +# [END secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_async.py new file mode 100644 index 0000000..2058d09 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DestroySecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_destroy_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DestroySecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.destroy_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_sync.py new file mode 100644 index 0000000..89be192 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DestroySecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_destroy_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DestroySecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.destroy_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_async.py new file mode 100644 index 0000000..6c30144 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DisableSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_disable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DisableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.disable_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_sync.py new file mode 100644 index 0000000..0f460f6 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DisableSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_disable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.DisableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.disable_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_async.py new file mode 100644 index 0000000..757a04a --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for EnableSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_enable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.EnableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.enable_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_sync.py new file mode 100644 index 0000000..b516b3b --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for EnableSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_enable_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.EnableSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.enable_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_async.py new file mode 100644 index 0000000..f7fc250 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_get_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_sync.py new file mode 100644 index 0000000..d08d6b1 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_get_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_async.py new file mode 100644 index 0000000..0c2df85 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetSecret_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_get_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretRequest( + name="name_value", + ) + + # Make the request + response = await client.get_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetSecret_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_sync.py new file mode 100644 index 0000000..984fb8c --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetSecret_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_get_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretRequest( + name="name_value", + ) + + # Make the request + response = client.get_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetSecret_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_async.py new file mode 100644 index 0000000..59eaf1b --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_get_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_sync.py new file mode 100644 index 0000000..04e9366 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecretVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_get_secret_version(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.GetSecretVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_secret_version(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_async.py new file mode 100644 index 0000000..a8dcfcd --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecretVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_list_secret_versions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secret_versions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_sync.py new file mode 100644 index 0000000..d8b9c59 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecretVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_list_secret_versions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secret_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_async.py new file mode 100644 index 0000000..7ea9a57 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecrets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_list_secrets(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secrets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_sync.py new file mode 100644 index 0000000..8a70414 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_list_secrets_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecrets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_list_secrets(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.ListSecretsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_secrets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_async.py new file mode 100644 index 0000000..bfe08e6 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_set_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_sync.py new file mode 100644 index 0000000..6216435 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_set_iam_policy(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_async.py new file mode 100644 index 0000000..1342ec6 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_test_iam_permissions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_sync.py new file mode 100644 index 0000000..fa73cb7 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_test_iam_permissions(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_sync] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_async.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_async.py new file mode 100644 index 0000000..508ea9c --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +async def sample_update_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceAsyncClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.UpdateSecretRequest( + ) + + # Make the request + response = await client.update_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_async] diff --git a/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_sync.py b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_sync.py new file mode 100644 index 0000000..8ddcbe7 --- /dev/null +++ b/samples/generated_samples/secretmanager_v1beta1_generated_secret_manager_service_update_secret_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecret +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-secretmanager + + +# [START secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import secretmanager_v1beta1 + + +def sample_update_secret(): + # Create a client + client = secretmanager_v1beta1.SecretManagerServiceClient() + + # Initialize request argument(s) + request = secretmanager_v1beta1.UpdateSecretRequest( + ) + + # Make the request + response = client.update_secret(request=request) + + # Handle the response + print(response) + +# [END secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_sync] diff --git a/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json b/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json new file mode 100644 index 0000000..52f1d4e --- /dev/null +++ b/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json @@ -0,0 +1,2432 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.secrets.v1beta1", + "version": "v1beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-secretmanager", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.access_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.AccessSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "AccessSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse", + "shortName": "access_secret_version" + }, + "description": "Sample for AccessSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.access_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.AccessSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "AccessSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse", + "shortName": "access_secret_version" + }, + "description": "Sample for AccessSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_AccessSecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_access_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.add_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.AddSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "AddSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "payload", + "type": "google.cloud.secretmanager_v1beta1.types.SecretPayload" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "add_secret_version" + }, + "description": "Sample for AddSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.add_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.AddSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "AddSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.AddSecretVersionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "payload", + "type": "google.cloud.secretmanager_v1beta1.types.SecretPayload" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "add_secret_version" + }, + "description": "Sample for AddSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_AddSecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_add_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.create_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.CreateSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "CreateSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.CreateSecretRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "secret_id", + "type": "str" + }, + { + "name": "secret", + "type": "google.cloud.secretmanager_v1beta1.types.Secret" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "create_secret" + }, + "description": "Sample for CreateSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_create_secret_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_create_secret_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.create_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.CreateSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "CreateSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.CreateSecretRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "secret_id", + "type": "str" + }, + { + "name": "secret", + "type": "google.cloud.secretmanager_v1beta1.types.Secret" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "create_secret" + }, + "description": "Sample for CreateSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_create_secret_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_CreateSecret_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_create_secret_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.delete_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DeleteSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DeleteSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_secret" + }, + "description": "Sample for DeleteSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_delete_secret_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_delete_secret_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.delete_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DeleteSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DeleteSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DeleteSecretRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_secret" + }, + "description": "Sample for DeleteSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_delete_secret_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DeleteSecret_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_delete_secret_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.destroy_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DestroySecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DestroySecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "destroy_secret_version" + }, + "description": "Sample for DestroySecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.destroy_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DestroySecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DestroySecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DestroySecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "destroy_secret_version" + }, + "description": "Sample for DestroySecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DestroySecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_destroy_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.disable_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DisableSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DisableSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "disable_secret_version" + }, + "description": "Sample for DisableSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.disable_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.DisableSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "DisableSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.DisableSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "disable_secret_version" + }, + "description": "Sample for DisableSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_DisableSecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_disable_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.enable_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.EnableSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "EnableSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "enable_secret_version" + }, + "description": "Sample for EnableSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.enable_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.EnableSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "EnableSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.EnableSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "enable_secret_version" + }, + "description": "Sample for EnableSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_EnableSecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_enable_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.get_iam_policy", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetIamPolicy", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.get_iam_policy", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetIamPolicy", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.get_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "get_secret_version" + }, + "description": "Sample for GetSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.get_secret_version", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetSecretVersion", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetSecretVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.GetSecretVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", + "shortName": "get_secret_version" + }, + "description": "Sample for GetSecretVersion", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetSecretVersion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.get_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.GetSecretRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "get_secret" + }, + "description": "Sample for GetSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetSecret_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.get_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.GetSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "GetSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.GetSecretRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "get_secret" + }, + "description": "Sample for GetSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_GetSecret_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_get_secret_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.list_secret_versions", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.ListSecretVersions", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "ListSecretVersions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager", + "shortName": "list_secret_versions" + }, + "description": "Sample for ListSecretVersions", + "file": "secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.list_secret_versions", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.ListSecretVersions", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "ListSecretVersions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.ListSecretVersionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsPager", + "shortName": "list_secret_versions" + }, + "description": "Sample for ListSecretVersions", + "file": "secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_ListSecretVersions_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_list_secret_versions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.list_secrets", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.ListSecrets", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "ListSecrets" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.ListSecretsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsAsyncPager", + "shortName": "list_secrets" + }, + "description": "Sample for ListSecrets", + "file": "secretmanager_v1beta1_generated_secret_manager_service_list_secrets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_list_secrets_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.list_secrets", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.ListSecrets", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "ListSecrets" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.ListSecretsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsPager", + "shortName": "list_secrets" + }, + "description": "Sample for ListSecrets", + "file": "secretmanager_v1beta1_generated_secret_manager_service_list_secrets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_ListSecrets_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_list_secrets_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.set_iam_policy", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.SetIamPolicy", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.set_iam_policy", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.SetIamPolicy", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_SetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_set_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.TestIamPermissions", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.TestIamPermissions", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_TestIamPermissions_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_test_iam_permissions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient", + "shortName": "SecretManagerServiceAsyncClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceAsyncClient.update_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.UpdateSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "UpdateSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest" + }, + { + "name": "secret", + "type": "google.cloud.secretmanager_v1beta1.types.Secret" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "update_secret" + }, + "description": "Sample for UpdateSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_update_secret_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_update_secret_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient", + "shortName": "SecretManagerServiceClient" + }, + "fullName": "google.cloud.secretmanager_v1beta1.SecretManagerServiceClient.update_secret", + "method": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService.UpdateSecret", + "service": { + "fullName": "google.cloud.secrets.v1beta1.SecretManagerService", + "shortName": "SecretManagerService" + }, + "shortName": "UpdateSecret" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.secretmanager_v1beta1.types.UpdateSecretRequest" + }, + { + "name": "secret", + "type": "google.cloud.secretmanager_v1beta1.types.Secret" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", + "shortName": "update_secret" + }, + "description": "Sample for UpdateSecret", + "file": "secretmanager_v1beta1_generated_secret_manager_service_update_secret_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "secretmanager_v1beta1_generated_SecretManagerService_UpdateSecret_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "secretmanager_v1beta1_generated_secret_manager_service_update_secret_sync.py" + } + ] +} diff --git a/scripts/fixup_secretmanager_v1beta1_keywords.py b/scripts/fixup_secretmanager_v1beta1_keywords.py index 2b141b2..58891a7 100644 --- a/scripts/fixup_secretmanager_v1beta1_keywords.py +++ b/scripts/fixup_secretmanager_v1beta1_keywords.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,22 +39,21 @@ def partition( class secretmanagerCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - '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', ), - 'get_iam_policy': ('resource', 'options', ), - 'get_secret': ('name', ), - 'get_secret_version': ('name', ), - 'list_secrets': ('parent', 'page_size', 'page_token', ), - 'list_secret_versions': ('parent', 'page_size', 'page_token', ), - 'set_iam_policy': ('resource', 'policy', ), - 'test_iam_permissions': ('resource', 'permissions', ), - 'update_secret': ('secret', 'update_mask', ), - + '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', ), + 'get_iam_policy': ('resource', 'options', ), + 'get_secret': ('name', ), + 'get_secret_version': ('name', ), + 'list_secrets': ('parent', 'page_size', 'page_token', ), + 'list_secret_versions': ('parent', 'page_size', 'page_token', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), + 'test_iam_permissions': ('resource', 'permissions', ), + 'update_secret': ('secret', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -75,7 +72,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) @@ -87,7 +84,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/setup.py b/setup.py index 0da8ccf..1da0ae5 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, < 1.0.0dev", diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 883a87a..2beecf9 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -4,7 +4,7 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.33.2 +google-api-core==1.34.0 proto-plus==1.22.0 protobuf==3.19.5 grpc-google-iam-v1==0.12.4 diff --git a/tests/unit/gapic/secretmanager_v1beta1/__init__.py b/tests/unit/gapic/secretmanager_v1beta1/__init__.py index 42ffdf2..e8e1c38 100644 --- a/tests/unit/gapic/secretmanager_v1beta1/__init__.py +++ b/tests/unit/gapic/secretmanager_v1beta1/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py b/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py index ddfd27c..27b699b 100644 --- a/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py +++ b/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,33 +13,36 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import os + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock import math -import os -from google.api_core import ( - client_options, - exceptions, - gapic_v1, - grpc_helpers, - grpc_helpers_async, -) -from google.auth import credentials +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +import google.auth +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import options_pb2 as options # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import options_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account -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 +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore import grpc from grpc.experimental import aio -import mock +from proto.marshal.rules import wrappers from proto.marshal.rules.dates import DurationRule, TimestampRule import pytest -from google import auth from google.cloud.secretmanager_v1beta1.services.secret_manager_service import ( SecretManagerServiceAsyncClient, SecretManagerServiceClient, @@ -96,48 +98,81 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SecretManagerServiceClient, - SecretManagerServiceAsyncClient, + (SecretManagerServiceClient, "grpc"), + (SecretManagerServiceAsyncClient, "grpc_asyncio"), ], ) -def test_secret_manager_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() +def test_secret_manager_service_client_from_service_account_info( + client_class, transport_name +): + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == ("secretmanager.googleapis.com:443") + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.SecretManagerServiceGrpcTransport, "grpc"), + (transports.SecretManagerServiceGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_secret_manager_service_client_service_account_always_use_jwt( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SecretManagerServiceClient, - SecretManagerServiceAsyncClient, + (SecretManagerServiceClient, "grpc"), + (SecretManagerServiceAsyncClient, "grpc_asyncio"), ], ) -def test_secret_manager_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() +def test_secret_manager_service_client_from_service_account_file( + client_class, transport_name +): + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == ("secretmanager.googleapis.com:443") def test_secret_manager_service_client_get_transport_class(): @@ -181,7 +216,7 @@ def test_secret_manager_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(SecretManagerServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -194,7 +229,7 @@ def test_secret_manager_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -203,6 +238,8 @@ def test_secret_manager_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -210,7 +247,7 @@ def test_secret_manager_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -219,6 +256,8 @@ def test_secret_manager_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -226,7 +265,7 @@ def test_secret_manager_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -235,26 +274,28 @@ def test_secret_manager_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -263,6 +304,26 @@ def test_secret_manager_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -322,7 +383,7 @@ def test_secret_manager_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -339,6 +400,8 @@ def test_secret_manager_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -363,7 +426,7 @@ def test_secret_manager_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -372,6 +435,8 @@ def test_secret_manager_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -384,7 +449,7 @@ def test_secret_manager_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -393,9 +458,92 @@ def test_secret_manager_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) +@pytest.mark.parametrize( + "client_class", [SecretManagerServiceClient, SecretManagerServiceAsyncClient] +) +@mock.patch.object( + SecretManagerServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecretManagerServiceClient), +) +@mock.patch.object( + SecretManagerServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecretManagerServiceAsyncClient), +) +def test_secret_manager_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -420,7 +568,7 @@ def test_secret_manager_service_client_client_options_scopes( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -429,32 +577,37 @@ def test_secret_manager_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( SecretManagerServiceClient, transports.SecretManagerServiceGrpcTransport, "grpc", + grpc_helpers, ), ( SecretManagerServiceAsyncClient, transports.SecretManagerServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_secret_manager_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -463,6 +616,8 @@ def test_secret_manager_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) @@ -482,12 +637,88 @@ def test_secret_manager_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, ) -def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsRequest): +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + SecretManagerServiceClient, + transports.SecretManagerServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + SecretManagerServiceAsyncClient, + transports.SecretManagerServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_secret_manager_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "secretmanager.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="secretmanager.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "request_type", + [ + service.ListSecretsRequest, + dict, + ], +) +def test_list_secrets(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -502,33 +733,24 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR next_page_token="next_page_token_value", total_size=1086, ) - response = client.list_secrets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSecretsPager) - assert response.next_page_token == "next_page_token_value" - assert response.total_size == 1086 -def test_list_secrets_from_dict(): - test_list_secrets(request_type=dict) - - def test_list_secrets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -537,7 +759,6 @@ def test_list_secrets_empty_call(): client.list_secrets() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretsRequest() @@ -546,7 +767,7 @@ async def test_list_secrets_async( transport: str = "grpc_asyncio", request_type=service.ListSecretsRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -563,20 +784,16 @@ async def test_list_secrets_async( total_size=1086, ) ) - response = await client.list_secrets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.total_size == 1086 @@ -587,18 +804,18 @@ async def test_list_secrets_async_from_dict(): def test_list_secrets_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListSecretsRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = service.ListSecretsResponse() - client.list_secrets(request) # Establish that the underlying gRPC stub method was called. @@ -610,27 +827,27 @@ def test_list_secrets_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_list_secrets_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListSecretsRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretsResponse() ) - await client.list_secrets(request) # Establish that the underlying gRPC stub method was called. @@ -642,20 +859,19 @@ async def test_list_secrets_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] def test_list_secrets_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_secrets( @@ -666,13 +882,14 @@ def test_list_secrets_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_secrets_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -687,7 +904,7 @@ def test_list_secrets_flattened_error(): @pytest.mark.asyncio async def test_list_secrets_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -708,14 +925,15 @@ async def test_list_secrets_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio async def test_list_secrets_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -727,9 +945,10 @@ async def test_list_secrets_flattened_error_async(): ) -def test_list_secrets_pager(): +def test_list_secrets_pager(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -771,14 +990,15 @@ def test_list_secrets_pager(): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, resources.Secret) for i in results) -def test_list_secrets_pages(): +def test_list_secrets_pages(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -819,7 +1039,7 @@ def test_list_secrets_pages(): @pytest.mark.asyncio async def test_list_secrets_async_pager(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -859,7 +1079,7 @@ async def test_list_secrets_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -869,7 +1089,7 @@ async def test_list_secrets_async_pager(): @pytest.mark.asyncio async def test_list_secrets_async_pages(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -905,17 +1125,24 @@ async def test_list_secrets_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_secrets(request={})).pages: + async for page_ in ( + await client.list_secrets(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_create_secret( - transport: str = "grpc", request_type=service.CreateSecretRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.CreateSecretRequest, + dict, + ], +) +def test_create_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -929,31 +1156,23 @@ def test_create_secret( call.return_value = resources.Secret( name="name_value", ) - response = client.create_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Secret) - assert response.name == "name_value" -def test_create_secret_from_dict(): - test_create_secret(request_type=dict) - - def test_create_secret_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -962,7 +1181,6 @@ def test_create_secret_empty_call(): client.create_secret() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateSecretRequest() @@ -971,7 +1189,7 @@ async def test_create_secret_async( transport: str = "grpc_asyncio", request_type=service.CreateSecretRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -987,18 +1205,15 @@ async def test_create_secret_async( name="name_value", ) ) - response = await client.create_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) - assert response.name == "name_value" @@ -1009,18 +1224,18 @@ async def test_create_secret_async_from_dict(): def test_create_secret_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateSecretRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = resources.Secret() - client.create_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1032,25 +1247,25 @@ def test_create_secret_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_create_secret_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateSecretRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) - await client.create_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1062,20 +1277,19 @@ async def test_create_secret_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] def test_create_secret_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # 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() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_secret( @@ -1088,17 +1302,20 @@ def test_create_secret_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].secret_id == "secret_id_value" - - assert args[0].secret == resources.Secret(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].secret_id + mock_val = "secret_id_value" + assert arg == mock_val + arg = args[0].secret + mock_val = resources.Secret(name="name_value") + assert arg == mock_val def test_create_secret_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1115,7 +1332,7 @@ def test_create_secret_flattened_error(): @pytest.mark.asyncio async def test_create_secret_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1136,18 +1353,21 @@ async def test_create_secret_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].secret_id == "secret_id_value" - - assert args[0].secret == resources.Secret(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].secret_id + mock_val = "secret_id_value" + assert arg == mock_val + arg = args[0].secret + mock_val = resources.Secret(name="name_value") + assert arg == mock_val @pytest.mark.asyncio async def test_create_secret_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1161,11 +1381,16 @@ async def test_create_secret_flattened_error_async(): ) -def test_add_secret_version( - transport: str = "grpc", request_type=service.AddSecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.AddSecretVersionRequest, + dict, + ], +) +def test_add_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1182,33 +1407,24 @@ def test_add_secret_version( name="name_value", state=resources.SecretVersion.State.ENABLED, ) - response = client.add_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED -def test_add_secret_version_from_dict(): - test_add_secret_version(request_type=dict) - - def test_add_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -1219,7 +1435,6 @@ def test_add_secret_version_empty_call(): client.add_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.AddSecretVersionRequest() @@ -1228,7 +1443,7 @@ async def test_add_secret_version_async( transport: str = "grpc_asyncio", request_type=service.AddSecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1247,20 +1462,16 @@ async def test_add_secret_version_async( state=resources.SecretVersion.State.ENABLED, ) ) - response = await client.add_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED @@ -1271,20 +1482,20 @@ async def test_add_secret_version_async_from_dict(): def test_add_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.AddSecretVersionRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.add_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() - client.add_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -1296,20 +1507,21 @@ def test_add_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_add_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.AddSecretVersionRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1318,7 +1530,6 @@ async def test_add_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() ) - await client.add_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -1330,13 +1541,13 @@ async def test_add_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] def test_add_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1345,7 +1556,6 @@ def test_add_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.add_secret_version( @@ -1357,15 +1567,17 @@ def test_add_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].payload == resources.SecretPayload(data=b"data_blob") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].payload + mock_val = resources.SecretPayload(data=b"data_blob") + assert arg == mock_val def test_add_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1381,7 +1593,7 @@ def test_add_secret_version_flattened_error(): @pytest.mark.asyncio async def test_add_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1405,16 +1617,18 @@ async def test_add_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].payload == resources.SecretPayload(data=b"data_blob") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].payload + mock_val = resources.SecretPayload(data=b"data_blob") + assert arg == mock_val @pytest.mark.asyncio async def test_add_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1427,9 +1641,16 @@ async def test_add_secret_version_flattened_error_async(): ) -def test_get_secret(transport: str = "grpc", request_type=service.GetSecretRequest): +@pytest.mark.parametrize( + "request_type", + [ + service.GetSecretRequest, + dict, + ], +) +def test_get_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1443,31 +1664,23 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque call.return_value = resources.Secret( name="name_value", ) - response = client.get_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Secret) - assert response.name == "name_value" -def test_get_secret_from_dict(): - test_get_secret(request_type=dict) - - def test_get_secret_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -1476,7 +1689,6 @@ def test_get_secret_empty_call(): client.get_secret() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretRequest() @@ -1485,7 +1697,7 @@ async def test_get_secret_async( transport: str = "grpc_asyncio", request_type=service.GetSecretRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1501,18 +1713,15 @@ async def test_get_secret_async( name="name_value", ) ) - response = await client.get_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) - assert response.name == "name_value" @@ -1523,18 +1732,18 @@ async def test_get_secret_async_from_dict(): def test_get_secret_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetSecretRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = resources.Secret() - client.get_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1546,25 +1755,25 @@ def test_get_secret_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_get_secret_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetSecretRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) - await client.get_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1576,20 +1785,19 @@ async def test_get_secret_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_get_secret_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # 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() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_secret( @@ -1600,13 +1808,14 @@ def test_get_secret_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_secret_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1621,7 +1830,7 @@ def test_get_secret_flattened_error(): @pytest.mark.asyncio async def test_get_secret_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1640,14 +1849,15 @@ async def test_get_secret_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_get_secret_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1659,11 +1869,16 @@ async def test_get_secret_flattened_error_async(): ) -def test_update_secret( - transport: str = "grpc", request_type=service.UpdateSecretRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateSecretRequest, + dict, + ], +) +def test_update_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1677,31 +1892,23 @@ def test_update_secret( call.return_value = resources.Secret( name="name_value", ) - response = client.update_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Secret) - assert response.name == "name_value" -def test_update_secret_from_dict(): - test_update_secret(request_type=dict) - - def test_update_secret_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -1710,7 +1917,6 @@ def test_update_secret_empty_call(): client.update_secret() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateSecretRequest() @@ -1719,7 +1925,7 @@ async def test_update_secret_async( transport: str = "grpc_asyncio", request_type=service.UpdateSecretRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1735,18 +1941,15 @@ async def test_update_secret_async( name="name_value", ) ) - response = await client.update_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) - assert response.name == "name_value" @@ -1757,18 +1960,18 @@ async def test_update_secret_async_from_dict(): def test_update_secret_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateSecretRequest() - request.secret.name = "secret.name/value" + + request.secret.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = resources.Secret() - client.update_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1780,25 +1983,25 @@ def test_update_secret_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "secret.name=secret.name/value", + "secret.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_update_secret_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateSecretRequest() - request.secret.name = "secret.name/value" + + request.secret.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) - await client.update_secret(request) # Establish that the underlying gRPC stub method was called. @@ -1810,40 +2013,41 @@ async def test_update_secret_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "secret.name=secret.name/value", + "secret.name=name_value", ) in kw["metadata"] def test_update_secret_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # 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() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_secret( secret=resources.Secret(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].secret == resources.Secret(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + arg = args[0].secret + mock_val = resources.Secret(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_secret_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1852,14 +2056,14 @@ def test_update_secret_flattened_error(): client.update_secret( service.UpdateSecretRequest(), secret=resources.Secret(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_secret_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1872,23 +2076,25 @@ async def test_update_secret_flattened_async(): # using the keyword arguments to the method. response = await client.update_secret( secret=resources.Secret(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].secret == resources.Secret(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + arg = args[0].secret + mock_val = resources.Secret(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio async def test_update_secret_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1897,15 +2103,20 @@ async def test_update_secret_flattened_error_async(): await client.update_secret( service.UpdateSecretRequest(), secret=resources.Secret(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_delete_secret( - transport: str = "grpc", request_type=service.DeleteSecretRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteSecretRequest, + dict, + ], +) +def test_delete_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1917,28 +2128,22 @@ def test_delete_secret( with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteSecretRequest() # Establish that the response is the type that we expect. assert response is None -def test_delete_secret_from_dict(): - test_delete_secret(request_type=dict) - - def test_delete_secret_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -1947,7 +2152,6 @@ def test_delete_secret_empty_call(): client.delete_secret() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteSecretRequest() @@ -1956,7 +2160,7 @@ async def test_delete_secret_async( transport: str = "grpc_asyncio", request_type=service.DeleteSecretRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1968,13 +2172,11 @@ async def test_delete_secret_async( with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_secret(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteSecretRequest() # Establish that the response is the type that we expect. @@ -1988,18 +2190,18 @@ async def test_delete_secret_async_from_dict(): def test_delete_secret_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteSecretRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = None - client.delete_secret(request) # Establish that the underlying gRPC stub method was called. @@ -2011,25 +2213,25 @@ def test_delete_secret_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_secret_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteSecretRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_secret(request) # Establish that the underlying gRPC stub method was called. @@ -2041,20 +2243,19 @@ async def test_delete_secret_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_delete_secret_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_secret( @@ -2065,13 +2266,14 @@ def test_delete_secret_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_secret_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2086,7 +2288,7 @@ def test_delete_secret_flattened_error(): @pytest.mark.asyncio async def test_delete_secret_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2105,14 +2307,15 @@ async def test_delete_secret_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_delete_secret_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2124,11 +2327,16 @@ async def test_delete_secret_flattened_error_async(): ) -def test_list_secret_versions( - transport: str = "grpc", request_type=service.ListSecretVersionsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.ListSecretVersionsRequest, + dict, + ], +) +def test_list_secret_versions(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2145,33 +2353,24 @@ def test_list_secret_versions( next_page_token="next_page_token_value", total_size=1086, ) - response = client.list_secret_versions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSecretVersionsPager) - assert response.next_page_token == "next_page_token_value" - assert response.total_size == 1086 -def test_list_secret_versions_from_dict(): - test_list_secret_versions(request_type=dict) - - def test_list_secret_versions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -2182,7 +2381,6 @@ def test_list_secret_versions_empty_call(): client.list_secret_versions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretVersionsRequest() @@ -2191,7 +2389,7 @@ async def test_list_secret_versions_async( transport: str = "grpc_asyncio", request_type=service.ListSecretVersionsRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2210,20 +2408,16 @@ async def test_list_secret_versions_async( total_size=1086, ) ) - response = await client.list_secret_versions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretVersionsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.total_size == 1086 @@ -2234,20 +2428,20 @@ async def test_list_secret_versions_async_from_dict(): def test_list_secret_versions_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListSecretVersionsRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.list_secret_versions), "__call__" ) as call: call.return_value = service.ListSecretVersionsResponse() - client.list_secret_versions(request) # Establish that the underlying gRPC stub method was called. @@ -2259,20 +2453,21 @@ def test_list_secret_versions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_list_secret_versions_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListSecretVersionsRequest() - request.parent = "parent/value" + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2281,7 +2476,6 @@ async def test_list_secret_versions_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretVersionsResponse() ) - await client.list_secret_versions(request) # Establish that the underlying gRPC stub method was called. @@ -2293,13 +2487,13 @@ async def test_list_secret_versions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] def test_list_secret_versions_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2308,7 +2502,6 @@ def test_list_secret_versions_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_secret_versions( @@ -2319,13 +2512,14 @@ def test_list_secret_versions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_secret_versions_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2340,7 +2534,7 @@ def test_list_secret_versions_flattened_error(): @pytest.mark.asyncio async def test_list_secret_versions_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2363,14 +2557,15 @@ async def test_list_secret_versions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio async def test_list_secret_versions_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2382,9 +2577,10 @@ async def test_list_secret_versions_flattened_error_async(): ) -def test_list_secret_versions_pager(): +def test_list_secret_versions_pager(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2428,14 +2624,15 @@ def test_list_secret_versions_pager(): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, resources.SecretVersion) for i in results) -def test_list_secret_versions_pages(): +def test_list_secret_versions_pages(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2478,7 +2675,7 @@ def test_list_secret_versions_pages(): @pytest.mark.asyncio async def test_list_secret_versions_async_pager(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2520,7 +2717,7 @@ async def test_list_secret_versions_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -2530,7 +2727,7 @@ async def test_list_secret_versions_async_pager(): @pytest.mark.asyncio async def test_list_secret_versions_async_pages(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2568,17 +2765,24 @@ async def test_list_secret_versions_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_secret_versions(request={})).pages: + async for page_ in ( + await client.list_secret_versions(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_secret_version( - transport: str = "grpc", request_type=service.GetSecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.GetSecretVersionRequest, + dict, + ], +) +def test_get_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2595,33 +2799,24 @@ def test_get_secret_version( name="name_value", state=resources.SecretVersion.State.ENABLED, ) - response = client.get_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED -def test_get_secret_version_from_dict(): - test_get_secret_version(request_type=dict) - - def test_get_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -2632,7 +2827,6 @@ def test_get_secret_version_empty_call(): client.get_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretVersionRequest() @@ -2641,7 +2835,7 @@ async def test_get_secret_version_async( transport: str = "grpc_asyncio", request_type=service.GetSecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2660,20 +2854,16 @@ async def test_get_secret_version_async( state=resources.SecretVersion.State.ENABLED, ) ) - response = await client.get_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED @@ -2684,20 +2874,20 @@ async def test_get_secret_version_async_from_dict(): def test_get_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() - client.get_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -2709,20 +2899,21 @@ def test_get_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_get_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2731,7 +2922,6 @@ async def test_get_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() ) - await client.get_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -2743,13 +2933,13 @@ async def test_get_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_get_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2758,7 +2948,6 @@ def test_get_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_secret_version( @@ -2769,13 +2958,14 @@ def test_get_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2790,7 +2980,7 @@ def test_get_secret_version_flattened_error(): @pytest.mark.asyncio async def test_get_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2813,14 +3003,15 @@ async def test_get_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_get_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2832,11 +3023,16 @@ async def test_get_secret_version_flattened_error_async(): ) -def test_access_secret_version( - transport: str = "grpc", request_type=service.AccessSecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.AccessSecretVersionRequest, + dict, + ], +) +def test_access_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2852,31 +3048,23 @@ def test_access_secret_version( call.return_value = service.AccessSecretVersionResponse( name="name_value", ) - response = client.access_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.AccessSecretVersionResponse) - assert response.name == "name_value" -def test_access_secret_version_from_dict(): - test_access_secret_version(request_type=dict) - - def test_access_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -2887,7 +3075,6 @@ def test_access_secret_version_empty_call(): client.access_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.AccessSecretVersionRequest() @@ -2896,7 +3083,7 @@ async def test_access_secret_version_async( transport: str = "grpc_asyncio", request_type=service.AccessSecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2914,18 +3101,15 @@ async def test_access_secret_version_async( name="name_value", ) ) - response = await client.access_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, service.AccessSecretVersionResponse) - assert response.name == "name_value" @@ -2936,20 +3120,20 @@ async def test_access_secret_version_async_from_dict(): def test_access_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.AccessSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.access_secret_version), "__call__" ) as call: call.return_value = service.AccessSecretVersionResponse() - client.access_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -2961,20 +3145,21 @@ def test_access_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_access_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.AccessSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2983,7 +3168,6 @@ async def test_access_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.AccessSecretVersionResponse() ) - await client.access_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -2995,13 +3179,13 @@ async def test_access_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_access_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3010,7 +3194,6 @@ def test_access_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.access_secret_version( @@ -3021,13 +3204,14 @@ def test_access_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_access_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3042,7 +3226,7 @@ def test_access_secret_version_flattened_error(): @pytest.mark.asyncio async def test_access_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3065,14 +3249,15 @@ async def test_access_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_access_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3084,11 +3269,16 @@ async def test_access_secret_version_flattened_error_async(): ) -def test_disable_secret_version( - transport: str = "grpc", request_type=service.DisableSecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.DisableSecretVersionRequest, + dict, + ], +) +def test_disable_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3105,33 +3295,24 @@ def test_disable_secret_version( name="name_value", state=resources.SecretVersion.State.ENABLED, ) - response = client.disable_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED -def test_disable_secret_version_from_dict(): - test_disable_secret_version(request_type=dict) - - def test_disable_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -3142,7 +3323,6 @@ def test_disable_secret_version_empty_call(): client.disable_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableSecretVersionRequest() @@ -3151,7 +3331,7 @@ async def test_disable_secret_version_async( transport: str = "grpc_asyncio", request_type=service.DisableSecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3170,20 +3350,16 @@ async def test_disable_secret_version_async( state=resources.SecretVersion.State.ENABLED, ) ) - response = await client.disable_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED @@ -3194,20 +3370,20 @@ async def test_disable_secret_version_async_from_dict(): def test_disable_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.disable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() - client.disable_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3219,20 +3395,21 @@ def test_disable_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_disable_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3241,7 +3418,6 @@ async def test_disable_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() ) - await client.disable_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3253,13 +3429,13 @@ async def test_disable_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_disable_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3268,7 +3444,6 @@ def test_disable_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.disable_secret_version( @@ -3279,13 +3454,14 @@ def test_disable_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_disable_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3300,7 +3476,7 @@ def test_disable_secret_version_flattened_error(): @pytest.mark.asyncio async def test_disable_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3323,14 +3499,15 @@ async def test_disable_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_disable_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3342,11 +3519,16 @@ async def test_disable_secret_version_flattened_error_async(): ) -def test_enable_secret_version( - transport: str = "grpc", request_type=service.EnableSecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.EnableSecretVersionRequest, + dict, + ], +) +def test_enable_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3363,33 +3545,24 @@ def test_enable_secret_version( name="name_value", state=resources.SecretVersion.State.ENABLED, ) - response = client.enable_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED -def test_enable_secret_version_from_dict(): - test_enable_secret_version(request_type=dict) - - def test_enable_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -3400,7 +3573,6 @@ def test_enable_secret_version_empty_call(): client.enable_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableSecretVersionRequest() @@ -3409,7 +3581,7 @@ async def test_enable_secret_version_async( transport: str = "grpc_asyncio", request_type=service.EnableSecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3428,20 +3600,16 @@ async def test_enable_secret_version_async( state=resources.SecretVersion.State.ENABLED, ) ) - response = await client.enable_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED @@ -3452,20 +3620,20 @@ async def test_enable_secret_version_async_from_dict(): def test_enable_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.enable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() - client.enable_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3477,20 +3645,21 @@ def test_enable_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_enable_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableSecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3499,7 +3668,6 @@ async def test_enable_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() ) - await client.enable_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3511,13 +3679,13 @@ async def test_enable_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_enable_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3526,7 +3694,6 @@ def test_enable_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.enable_secret_version( @@ -3537,13 +3704,14 @@ def test_enable_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_enable_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3558,7 +3726,7 @@ def test_enable_secret_version_flattened_error(): @pytest.mark.asyncio async def test_enable_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3581,14 +3749,15 @@ async def test_enable_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_enable_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3600,11 +3769,16 @@ async def test_enable_secret_version_flattened_error_async(): ) -def test_destroy_secret_version( - transport: str = "grpc", request_type=service.DestroySecretVersionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + service.DestroySecretVersionRequest, + dict, + ], +) +def test_destroy_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3621,33 +3795,24 @@ def test_destroy_secret_version( name="name_value", state=resources.SecretVersion.State.ENABLED, ) - response = client.destroy_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED -def test_destroy_secret_version_from_dict(): - test_destroy_secret_version(request_type=dict) - - def test_destroy_secret_version_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -3658,7 +3823,6 @@ def test_destroy_secret_version_empty_call(): client.destroy_secret_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DestroySecretVersionRequest() @@ -3667,7 +3831,7 @@ async def test_destroy_secret_version_async( transport: str = "grpc_asyncio", request_type=service.DestroySecretVersionRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3686,20 +3850,16 @@ async def test_destroy_secret_version_async( state=resources.SecretVersion.State.ENABLED, ) ) - response = await client.destroy_secret_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) - assert response.name == "name_value" - assert response.state == resources.SecretVersion.State.ENABLED @@ -3710,20 +3870,20 @@ async def test_destroy_secret_version_async_from_dict(): def test_destroy_secret_version_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DestroySecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.destroy_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() - client.destroy_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3735,20 +3895,21 @@ def test_destroy_secret_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_destroy_secret_version_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DestroySecretVersionRequest() - request.name = "name/value" + + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3757,7 +3918,6 @@ async def test_destroy_secret_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() ) - await client.destroy_secret_version(request) # Establish that the underlying gRPC stub method was called. @@ -3769,13 +3929,13 @@ async def test_destroy_secret_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] def test_destroy_secret_version_flattened(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3784,7 +3944,6 @@ def test_destroy_secret_version_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.destroy_secret_version( @@ -3795,13 +3954,14 @@ def test_destroy_secret_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_destroy_secret_version_flattened_error(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3816,7 +3976,7 @@ def test_destroy_secret_version_flattened_error(): @pytest.mark.asyncio async def test_destroy_secret_version_flattened_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3839,14 +3999,15 @@ async def test_destroy_secret_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio async def test_destroy_secret_version_flattened_error_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3858,11 +4019,16 @@ async def test_destroy_secret_version_flattened_error_async(): ) -def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy.SetIamPolicyRequest -): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) +def test_set_iam_policy(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3873,37 +4039,28 @@ def test_set_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy( + call.return_value = policy_pb2.Policy( version=774, etag=b"etag_blob", ) - response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" -def test_set_iam_policy_from_dict(): - test_set_iam_policy(request_type=dict) - - def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -3912,16 +4069,15 @@ def test_set_iam_policy_empty_call(): client.set_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() @pytest.mark.asyncio async def test_set_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3933,25 +4089,21 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy( + policy_pb2.Policy( version=774, etag=b"etag_blob", ) ) - response = await client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -3962,18 +4114,18 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.SetIamPolicyRequest() - request.resource = "resource/value" + request = iam_policy_pb2.SetIamPolicyRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -3985,25 +4137,25 @@ def test_set_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.SetIamPolicyRequest() - request.resource = "resource/value" + request = iam_policy_pb2.SetIamPolicyRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) await client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -4015,33 +4167,38 @@ async def test_set_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() response = client.set_iam_policy( request={ "resource": "resource_value", - "policy": policy.Policy(version=774), + "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() -def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy.GetIamPolicyRequest -): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) +def test_get_iam_policy(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4052,37 +4209,28 @@ def test_get_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy( + call.return_value = policy_pb2.Policy( version=774, etag=b"etag_blob", ) - response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" -def test_get_iam_policy_from_dict(): - test_get_iam_policy(request_type=dict) - - def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -4091,16 +4239,15 @@ def test_get_iam_policy_empty_call(): client.get_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() @pytest.mark.asyncio async def test_get_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4112,25 +4259,21 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy( + policy_pb2.Policy( version=774, etag=b"etag_blob", ) ) - response = await client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -4141,18 +4284,18 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.GetIamPolicyRequest() - request.resource = "resource/value" + request = iam_policy_pb2.GetIamPolicyRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -4164,25 +4307,25 @@ def test_get_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.GetIamPolicyRequest() - request.resource = "resource/value" + request = iam_policy_pb2.GetIamPolicyRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) await client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -4194,33 +4337,37 @@ async def test_get_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() response = client.get_iam_policy( request={ "resource": "resource_value", - "options": options.GetPolicyOptions(requested_policy_version=2598), + "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), } ) call.assert_called() -def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy.TestIamPermissionsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4233,34 +4380,26 @@ def test_test_iam_permissions( type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy.TestIamPermissionsResponse( + call.return_value = iam_policy_pb2.TestIamPermissionsResponse( permissions=["permissions_value"], ) - response = client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, iam_policy.TestIamPermissionsResponse) - + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] -def test_test_iam_permissions_from_dict(): - test_test_iam_permissions(request_type=dict) - - def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) @@ -4271,16 +4410,16 @@ def test_test_iam_permissions_empty_call(): client.test_iam_permissions() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() @pytest.mark.asyncio async def test_test_iam_permissions_async( - transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest + transport: str = "grpc_asyncio", + request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4294,22 +4433,19 @@ async def test_test_iam_permissions_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse( + iam_policy_pb2.TestIamPermissionsResponse( permissions=["permissions_value"], ) ) - response = await client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy.TestIamPermissionsResponse) - + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] @@ -4320,20 +4456,20 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.TestIamPermissionsRequest() - request.resource = "resource/value" + request = iam_policy_pb2.TestIamPermissionsRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" ) as call: - call.return_value = iam_policy.TestIamPermissionsResponse() - + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. @@ -4345,29 +4481,29 @@ def test_test_iam_permissions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): client = SecretManagerServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy.TestIamPermissionsRequest() - request.resource = "resource/value" + request = iam_policy_pb2.TestIamPermissionsRequest() + + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse() + iam_policy_pb2.TestIamPermissionsResponse() ) - await client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. @@ -4379,21 +4515,20 @@ async def test_test_iam_permissions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy.TestIamPermissionsResponse() - + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() response = client.test_iam_permissions( request={ "resource": "resource_value", @@ -4406,17 +4541,17 @@ def test_test_iam_permissions_from_dict_foreign(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.SecretManagerServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.SecretManagerServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SecretManagerServiceClient( @@ -4424,9 +4559,29 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SecretManagerServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecretManagerServiceClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecretManagerServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SecretManagerServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SecretManagerServiceClient( @@ -4438,7 +4593,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.SecretManagerServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = SecretManagerServiceClient(transport=transport) assert client.transport is transport @@ -4447,13 +4602,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.SecretManagerServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.SecretManagerServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -4468,16 +4623,29 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = SecretManagerServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, @@ -4487,9 +4655,9 @@ def test_transport_grpc_default(): def test_secret_manager_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.SecretManagerServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -4501,7 +4669,7 @@ def test_secret_manager_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.SecretManagerServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -4527,60 +4695,136 @@ def test_secret_manager_service_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_secret_manager_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.secretmanager_v1beta1.services.secret_manager_service.transports.SecretManagerServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SecretManagerServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_secret_manager_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.secretmanager_v1beta1.services.secret_manager_service.transports.SecretManagerServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SecretManagerServiceTransport() adc.assert_called_once() def test_secret_manager_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) SecretManagerServiceClient() adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) -def test_secret_manager_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.SecretManagerServiceGrpcTransport, + transports.SecretManagerServiceGrpcAsyncIOTransport, + ], +) +def test_secret_manager_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.SecretManagerServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" - ) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SecretManagerServiceGrpcTransport, + transports.SecretManagerServiceGrpcAsyncIOTransport, + ], +) +def test_secret_manager_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SecretManagerServiceGrpcTransport, grpc_helpers), + (transports.SecretManagerServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +def test_secret_manager_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "secretmanager.googleapis.com:443", + credentials=creds, + credentials_file=None, quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="secretmanager.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) @@ -4594,7 +4838,7 @@ def test_secret_manager_service_transport_auth_adc(): def test_secret_manager_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -4608,7 +4852,7 @@ def test_secret_manager_service_grpc_transport_client_cert_source_for_mtls( "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -4631,24 +4875,40 @@ def test_secret_manager_service_grpc_transport_client_cert_source_for_mtls( ) -def test_secret_manager_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_secret_manager_service_host_no_port(transport_name): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="secretmanager.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == ("secretmanager.googleapis.com:443") -def test_secret_manager_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_secret_manager_service_host_with_port(transport_name): client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="secretmanager.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "secretmanager.googleapis.com:8000" + assert client.transport._host == ("secretmanager.googleapis.com:8000") def test_secret_manager_service_grpc_transport_channel(): @@ -4701,9 +4961,9 @@ def test_secret_manager_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -4719,7 +4979,7 @@ def test_secret_manager_service_transport_channel_mtls_with_client_cert_source( "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -4766,7 +5026,7 @@ def test_secret_manager_service_transport_channel_mtls_with_adc(transport_class) "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -4780,7 +5040,6 @@ def test_secret_manager_service_transport_channel_mtls_with_adc(transport_class) def test_secret_path(): project = "squid" secret = "clam" - expected = "projects/{project}/secrets/{secret}".format( project=project, secret=secret, @@ -4805,7 +5064,6 @@ def test_secret_version_path(): project = "oyster" secret = "nudibranch" secret_version = "cuttlefish" - expected = "projects/{project}/secrets/{secret}/versions/{secret_version}".format( project=project, secret=secret, @@ -4832,7 +5090,6 @@ def test_parse_secret_version_path(): def test_common_billing_account_path(): billing_account = "scallop" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4853,7 +5110,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "squid" - expected = "folders/{folder}".format( folder=folder, ) @@ -4874,7 +5130,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "whelk" - expected = "organizations/{organization}".format( organization=organization, ) @@ -4895,7 +5150,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "oyster" - expected = "projects/{project}".format( project=project, ) @@ -4917,7 +5171,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "cuttlefish" location = "mussel" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -4938,14 +5191,14 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( transports.SecretManagerServiceTransport, "_prep_wrapped_messages" ) as prep: client = SecretManagerServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4955,7 +5208,88 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = SecretManagerServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SecretManagerServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SecretManagerServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = SecretManagerServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (SecretManagerServiceClient, transports.SecretManagerServiceGrpcTransport), + ( + SecretManagerServiceAsyncClient, + transports.SecretManagerServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + )