From b2c8ed54c360636ca2f0d59e1e4a57cc69ac50c0 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 7 Mar 2022 22:02:27 +0100 Subject: [PATCH 01/30] chore(deps): update all dependencies (#384) --- samples/snippets/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index e1d9dc88..a88b3c87 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,5 +1,5 @@ google-cloud-storage==2.1.0 -google-cloud-asset==3.8.0 -google-cloud-resource-manager==1.4.0 +google-cloud-asset==3.8.1 +google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.10.0 -google-cloud-bigquery==2.34.1 +google-cloud-bigquery==2.34.2 From a88769828efa761c78dc221557ab673d33876408 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 10 Mar 2022 11:41:56 +0100 Subject: [PATCH 02/30] chore(deps): update dependency google-cloud-pubsub to v2.11.0 (#385) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index a88b3c87..d108f50e 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,5 +1,5 @@ google-cloud-storage==2.1.0 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 -google-cloud-pubsub==2.10.0 +google-cloud-pubsub==2.11.0 google-cloud-bigquery==2.34.2 From fac908a34b6476e9047e640f334a337b360955ca Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 13 Mar 2022 21:06:25 +0100 Subject: [PATCH 03/30] chore(deps): update dependency pytest to v7.1.0 (#388) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index c4bb1f1c..67c3304f 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 flaky==3.7.0 -pytest==7.0.1 +pytest==7.1.0 From 55fb4bba5c456bb5cec703e3404acf39fa9d8678 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Mar 2022 18:41:50 +0100 Subject: [PATCH 04/30] chore(deps): update dependency google-cloud-storage to v2.2.0 (#389) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index d108f50e..e39c97fd 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-storage==2.1.0 +google-cloud-storage==2.2.0 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.11.0 From 3a3abcec58e2279a8cfa4a105bdad1d736dc446e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 15 Mar 2022 21:56:15 +0100 Subject: [PATCH 05/30] chore(deps): update dependency google-cloud-storage to v2.2.1 (#390) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index e39c97fd..83d8f1af 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-storage==2.2.0 +google-cloud-storage==2.2.1 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.11.0 From c162841783f960cf3f725073282520e37713101c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 19 Mar 2022 11:16:25 +0100 Subject: [PATCH 06/30] chore(deps): update dependency pytest to v7.1.1 (#391) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 67c3304f..8479de71 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 flaky==3.7.0 -pytest==7.1.0 +pytest==7.1.1 From 9a8bc484ba8e087b8e2bd314791579343a4f8f9b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:54:48 +0000 Subject: [PATCH 07/30] chore(python): use black==22.3.0 (#396) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 13 +- .../services/asset_service/async_client.py | 108 +- .../asset_v1/services/asset_service/client.py | 193 +++- .../services/asset_service/transports/base.py | 26 +- .../services/asset_service/transports/grpc.py | 3 +- google/cloud/asset_v1/types/asset_service.py | 596 ++++++++-- google/cloud/asset_v1/types/assets.py | 452 ++++++-- .../services/asset_service/async_client.py | 28 +- .../services/asset_service/client.py | 69 +- .../services/asset_service/transports/base.py | 10 +- .../services/asset_service/transports/grpc.py | 3 +- .../asset_v1p1beta1/types/asset_service.py | 68 +- google/cloud/asset_v1p1beta1/types/assets.py | 84 +- .../services/asset_service/async_client.py | 37 +- .../services/asset_service/client.py | 88 +- .../services/asset_service/transports/base.py | 18 +- .../services/asset_service/transports/grpc.py | 3 +- .../asset_v1p2beta1/types/asset_service.py | 93 +- google/cloud/asset_v1p2beta1/types/assets.py | 94 +- .../services/asset_service/async_client.py | 18 +- .../services/asset_service/client.py | 59 +- .../services/asset_service/transports/base.py | 10 +- .../services/asset_service/transports/grpc.py | 3 +- .../asset_v1p4beta1/types/asset_service.py | 177 ++- google/cloud/asset_v1p4beta1/types/assets.py | 106 +- .../services/asset_service/async_client.py | 16 +- .../services/asset_service/client.py | 81 +- .../services/asset_service/transports/base.py | 10 +- .../services/asset_service/transports/grpc.py | 3 +- .../asset_v1p5beta1/types/asset_service.py | 55 +- google/cloud/asset_v1p5beta1/types/assets.py | 68 +- noxfile.py | 9 +- samples/snippets/noxfile.py | 2 +- .../unit/gapic/asset_v1/test_asset_service.py | 1005 +++++++++++++---- .../asset_v1p1beta1/test_asset_service.py | 285 +++-- .../asset_v1p2beta1/test_asset_service.py | 397 +++++-- .../asset_v1p4beta1/test_asset_service.py | 145 ++- .../asset_v1p5beta1/test_asset_service.py | 236 +++- 39 files changed, 3644 insertions(+), 1029 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7c..87dd0061 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 9b9e60cb..38249472 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-asset", "google-cloud-asset Documentation", [author], 1,) + ( + root_doc, + "google-cloud-asset", + "google-cloud-asset Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/asset_v1/services/asset_service/async_client.py b/google/cloud/asset_v1/services/asset_service/async_client.py index 1426560c..0c02d6a2 100644 --- a/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1/services/asset_service/async_client.py @@ -302,7 +302,12 @@ def sample_export_assets(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -417,12 +422,20 @@ def sample_list_assets(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListAssetsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -505,7 +518,12 @@ def sample_batch_get_assets_history(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -614,7 +632,12 @@ def sample_create_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -720,7 +743,12 @@ def sample_get_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -823,7 +851,12 @@ def sample_list_feeds(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -925,7 +958,12 @@ def sample_update_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1018,7 +1056,10 @@ def sample_delete_feed(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def search_all_resources( @@ -1213,12 +1254,20 @@ def sample_search_all_resources(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.SearchAllResourcesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1395,12 +1444,20 @@ def sample_search_all_iam_policies(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.SearchAllIamPoliciesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1485,7 +1542,12 @@ def sample_analyze_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1582,7 +1644,12 @@ def sample_analyze_iam_policy_longrunning(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1666,7 +1733,12 @@ def sample_analyze_move(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1680,7 +1752,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1/services/asset_service/client.py b/google/cloud/asset_v1/services/asset_service/client.py index 05684ef9..2d13cd00 100644 --- a/google/cloud/asset_v1/services/asset_service/client.py +++ b/google/cloud/asset_v1/services/asset_service/client.py @@ -57,7 +57,10 @@ class AssetServiceClientMeta(type): _transport_registry["grpc"] = AssetServiceGrpcTransport _transport_registry["grpc_asyncio"] = AssetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[AssetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[AssetServiceTransport]: """Returns an appropriate transport class. Args: @@ -162,10 +165,14 @@ def transport(self) -> AssetServiceTransport: return self._transport @staticmethod - def access_level_path(access_policy: str, access_level: str,) -> str: + def access_level_path( + access_policy: str, + access_level: str, + ) -> str: """Returns a fully-qualified access_level string.""" return "accessPolicies/{access_policy}/accessLevels/{access_level}".format( - access_policy=access_policy, access_level=access_level, + access_policy=access_policy, + access_level=access_level, ) @staticmethod @@ -178,9 +185,13 @@ def parse_access_level_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def access_policy_path(access_policy: str,) -> str: + def access_policy_path( + access_policy: str, + ) -> str: """Returns a fully-qualified access_policy string.""" - return "accessPolicies/{access_policy}".format(access_policy=access_policy,) + return "accessPolicies/{access_policy}".format( + access_policy=access_policy, + ) @staticmethod def parse_access_policy_path(path: str) -> Dict[str, str]: @@ -194,9 +205,15 @@ def asset_path() -> str: return "*".format() @staticmethod - def feed_path(project: str, feed: str,) -> str: + def feed_path( + project: str, + feed: str, + ) -> str: """Returns a fully-qualified feed string.""" - return "projects/{project}/feeds/{feed}".format(project=project, feed=feed,) + return "projects/{project}/feeds/{feed}".format( + project=project, + feed=feed, + ) @staticmethod def parse_feed_path(path: str) -> Dict[str, str]: @@ -205,10 +222,16 @@ def parse_feed_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def inventory_path(project: str, location: str, instance: str,) -> str: + def inventory_path( + project: str, + location: str, + instance: str, + ) -> str: """Returns a fully-qualified inventory string.""" return "projects/{project}/locations/{location}/instances/{instance}/inventory".format( - project=project, location=location, instance=instance, + project=project, + location=location, + instance=instance, ) @staticmethod @@ -221,10 +244,14 @@ def parse_inventory_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def service_perimeter_path(access_policy: str, service_perimeter: str,) -> str: + def service_perimeter_path( + access_policy: str, + service_perimeter: str, + ) -> str: """Returns a fully-qualified service_perimeter string.""" return "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( - access_policy=access_policy, service_perimeter=service_perimeter, + access_policy=access_policy, + service_perimeter=service_perimeter, ) @staticmethod @@ -237,7 +264,9 @@ def parse_service_perimeter_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -250,9 +279,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -261,9 +294,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -272,9 +309,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -283,10 +324,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -549,7 +594,12 @@ def sample_export_assets(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -654,12 +704,20 @@ def sample_list_assets(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListAssetsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -733,7 +791,12 @@ def sample_batch_get_assets_history(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -842,7 +905,12 @@ def sample_create_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -938,7 +1006,12 @@ def sample_get_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1031,7 +1104,12 @@ def sample_list_feeds(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1133,7 +1211,12 @@ def sample_update_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1216,7 +1299,10 @@ def sample_delete_feed(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def search_all_resources( @@ -1402,12 +1488,20 @@ def sample_search_all_resources(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.SearchAllResourcesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1575,12 +1669,20 @@ def sample_search_all_iam_policies(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.SearchAllIamPoliciesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1657,7 +1759,12 @@ def sample_analyze_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1757,7 +1864,12 @@ def sample_analyze_iam_policy_longrunning(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1842,7 +1954,12 @@ def sample_analyze_move(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1863,7 +1980,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1/services/asset_service/transports/base.py b/google/cloud/asset_v1/services/asset_service/transports/base.py index 8b071d9f..48c85f11 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1/services/asset_service/transports/base.py @@ -32,7 +32,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -122,7 +124,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.export_assets: gapic_v1.method.wrap_method( - self.export_assets, default_timeout=60.0, client_info=client_info, + self.export_assets, + default_timeout=60.0, + client_info=client_info, ), self.list_assets: gapic_v1.method.wrap_method( self.list_assets, @@ -155,7 +159,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_feed: gapic_v1.method.wrap_method( - self.create_feed, default_timeout=60.0, client_info=client_info, + self.create_feed, + default_timeout=60.0, + client_info=client_info, ), self.get_feed: gapic_v1.method.wrap_method( self.get_feed, @@ -188,7 +194,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.update_feed: gapic_v1.method.wrap_method( - self.update_feed, default_timeout=60.0, client_info=client_info, + self.update_feed, + default_timeout=60.0, + client_info=client_info, ), self.delete_feed: gapic_v1.method.wrap_method( self.delete_feed, @@ -253,16 +261,18 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.analyze_move: gapic_v1.method.wrap_method( - self.analyze_move, default_timeout=None, client_info=client_info, + self.analyze_move, + default_timeout=None, + client_info=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! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/asset_v1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1/services/asset_service/transports/grpc.py index d4f96195..00b273a5 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1/services/asset_service/transports/grpc.py @@ -228,8 +228,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/asset_v1/types/asset_service.py b/google/cloud/asset_v1/types/asset_service.py index 1362c0cd..f96d53c8 100644 --- a/google/cloud/asset_v1/types/asset_service.py +++ b/google/cloud/asset_v1/types/asset_service.py @@ -89,7 +89,11 @@ class AnalyzeIamPolicyLongrunningMetadata(proto.Message): created. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) class ExportAssetsRequest(proto.Message): @@ -160,12 +164,33 @@ class ExportAssetsRequest(proto.Message): for all supported asset types and relationship types. """ - parent = proto.Field(proto.STRING, number=1,) - read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) - output_config = proto.Field(proto.MESSAGE, number=5, message="OutputConfig",) - relationship_types = proto.RepeatedField(proto.STRING, number=6,) + parent = proto.Field( + proto.STRING, + number=1, + ) + read_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + content_type = proto.Field( + proto.ENUM, + number=4, + enum="ContentType", + ) + output_config = proto.Field( + proto.MESSAGE, + number=5, + message="OutputConfig", + ) + relationship_types = proto.RepeatedField( + proto.STRING, + number=6, + ) class ExportAssetsResponse(proto.Message): @@ -190,9 +215,21 @@ class ExportAssetsResponse(proto.Message): it exceeds a single Google Cloud Storage object limit. """ - read_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - output_config = proto.Field(proto.MESSAGE, number=2, message="OutputConfig",) - output_result = proto.Field(proto.MESSAGE, number=3, message="OutputResult",) + read_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + output_config = proto.Field( + proto.MESSAGE, + number=2, + message="OutputConfig", + ) + output_result = proto.Field( + proto.MESSAGE, + number=3, + message="OutputResult", + ) class ListAssetsRequest(proto.Message): @@ -269,13 +306,36 @@ class ListAssetsRequest(proto.Message): for all supported asset types and relationship types. """ - parent = proto.Field(proto.STRING, number=1,) - read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) - page_size = proto.Field(proto.INT32, number=5,) - page_token = proto.Field(proto.STRING, number=6,) - relationship_types = proto.RepeatedField(proto.STRING, number=7,) + parent = proto.Field( + proto.STRING, + number=1, + ) + read_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + content_type = proto.Field( + proto.ENUM, + number=4, + enum="ContentType", + ) + page_size = proto.Field( + proto.INT32, + number=5, + ) + page_token = proto.Field( + proto.STRING, + number=6, + ) + relationship_types = proto.RepeatedField( + proto.STRING, + number=7, + ) class ListAssetsResponse(proto.Message): @@ -297,9 +357,20 @@ class ListAssetsResponse(proto.Message): def raw_page(self): return self - read_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - assets = proto.RepeatedField(proto.MESSAGE, number=2, message=gca_assets.Asset,) - next_page_token = proto.Field(proto.STRING, number=3,) + read_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + assets = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gca_assets.Asset, + ) + next_page_token = proto.Field( + proto.STRING, + number=3, + ) class BatchGetAssetsHistoryRequest(proto.Message): @@ -351,13 +422,28 @@ class BatchGetAssetsHistoryRequest(proto.Message): for all supported asset types and relationship types. """ - parent = proto.Field(proto.STRING, number=1,) - asset_names = proto.RepeatedField(proto.STRING, number=2,) - content_type = proto.Field(proto.ENUM, number=3, enum="ContentType",) + parent = proto.Field( + proto.STRING, + number=1, + ) + asset_names = proto.RepeatedField( + proto.STRING, + number=2, + ) + content_type = proto.Field( + proto.ENUM, + number=3, + enum="ContentType", + ) read_time_window = proto.Field( - proto.MESSAGE, number=4, message=gca_assets.TimeWindow, + proto.MESSAGE, + number=4, + message=gca_assets.TimeWindow, + ) + relationship_types = proto.RepeatedField( + proto.STRING, + number=5, ) - relationship_types = proto.RepeatedField(proto.STRING, number=5,) class BatchGetAssetsHistoryResponse(proto.Message): @@ -369,7 +455,9 @@ class BatchGetAssetsHistoryResponse(proto.Message): """ assets = proto.RepeatedField( - proto.MESSAGE, number=1, message=gca_assets.TemporalAsset, + proto.MESSAGE, + number=1, + message=gca_assets.TemporalAsset, ) @@ -398,9 +486,19 @@ class CreateFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - parent = proto.Field(proto.STRING, number=1,) - feed_id = proto.Field(proto.STRING, number=2,) - feed = proto.Field(proto.MESSAGE, number=3, message="Feed",) + parent = proto.Field( + proto.STRING, + number=1, + ) + feed_id = proto.Field( + proto.STRING, + number=2, + ) + feed = proto.Field( + proto.MESSAGE, + number=3, + message="Feed", + ) class GetFeedRequest(proto.Message): @@ -414,7 +512,10 @@ class GetFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListFeedsRequest(proto.Message): @@ -430,7 +531,10 @@ class ListFeedsRequest(proto.Message): "projects/my-project-id"). """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) class ListFeedsResponse(proto.Message): @@ -441,7 +545,11 @@ class ListFeedsResponse(proto.Message): A list of feeds. """ - feeds = proto.RepeatedField(proto.MESSAGE, number=1, message="Feed",) + feeds = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Feed", + ) class UpdateFeedRequest(proto.Message): @@ -460,9 +568,15 @@ class UpdateFeedRequest(proto.Message): contain fields that are immutable or only set by the server. """ - feed = proto.Field(proto.MESSAGE, number=1, message="Feed",) + feed = proto.Field( + proto.MESSAGE, + number=1, + message="Feed", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -477,7 +591,10 @@ class DeleteFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class OutputConfig(proto.Message): @@ -504,10 +621,16 @@ class OutputConfig(proto.Message): """ gcs_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message="GcsDestination", + proto.MESSAGE, + number=1, + oneof="destination", + message="GcsDestination", ) bigquery_destination = proto.Field( - proto.MESSAGE, number=2, oneof="destination", message="BigQueryDestination", + proto.MESSAGE, + number=2, + oneof="destination", + message="BigQueryDestination", ) @@ -524,7 +647,10 @@ class OutputResult(proto.Message): """ gcs_result = proto.Field( - proto.MESSAGE, number=1, oneof="result", message="GcsOutputResult", + proto.MESSAGE, + number=1, + oneof="result", + message="GcsOutputResult", ) @@ -537,7 +663,10 @@ class GcsOutputResult(proto.Message): "gs://bucket_name/object_name". """ - uris = proto.RepeatedField(proto.STRING, number=1,) + uris = proto.RepeatedField( + proto.STRING, + number=1, + ) class GcsDestination(proto.Message): @@ -578,8 +707,16 @@ class GcsDestination(proto.Message): This field is a member of `oneof`_ ``object_uri``. """ - uri = proto.Field(proto.STRING, number=1, oneof="object_uri",) - uri_prefix = proto.Field(proto.STRING, number=2, oneof="object_uri",) + uri = proto.Field( + proto.STRING, + number=1, + oneof="object_uri", + ) + uri_prefix = proto.Field( + proto.STRING, + number=2, + oneof="object_uri", + ) class BigQueryDestination(proto.Message): @@ -660,11 +797,27 @@ class BigQueryDestination(proto.Message): a table. """ - dataset = proto.Field(proto.STRING, number=1,) - table = proto.Field(proto.STRING, number=2,) - force = proto.Field(proto.BOOL, number=3,) - partition_spec = proto.Field(proto.MESSAGE, number=4, message="PartitionSpec",) - separate_tables_per_asset_type = proto.Field(proto.BOOL, number=5,) + dataset = proto.Field( + proto.STRING, + number=1, + ) + table = proto.Field( + proto.STRING, + number=2, + ) + force = proto.Field( + proto.BOOL, + number=3, + ) + partition_spec = proto.Field( + proto.MESSAGE, + number=4, + message="PartitionSpec", + ) + separate_tables_per_asset_type = proto.Field( + proto.BOOL, + number=5, + ) class PartitionSpec(proto.Message): @@ -688,7 +841,11 @@ class PartitionKey(proto.Enum): READ_TIME = 1 REQUEST_TIME = 2 - partition_key = proto.Field(proto.ENUM, number=1, enum=PartitionKey,) + partition_key = proto.Field( + proto.ENUM, + number=1, + enum=PartitionKey, + ) class PubsubDestination(proto.Message): @@ -700,7 +857,10 @@ class PubsubDestination(proto.Message): ``projects/PROJECT_ID/topics/TOPIC_ID``. """ - topic = proto.Field(proto.STRING, number=1,) + topic = proto.Field( + proto.STRING, + number=1, + ) class FeedOutputConfig(proto.Message): @@ -716,7 +876,10 @@ class FeedOutputConfig(proto.Message): """ pubsub_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message="PubsubDestination", + proto.MESSAGE, + number=1, + oneof="destination", + message="PubsubDestination", ) @@ -800,15 +963,37 @@ class Feed(proto.Message): for all supported asset types and relationship types. """ - name = proto.Field(proto.STRING, number=1,) - asset_names = proto.RepeatedField(proto.STRING, number=2,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_names = proto.RepeatedField( + proto.STRING, + number=2, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + content_type = proto.Field( + proto.ENUM, + number=4, + enum="ContentType", + ) feed_output_config = proto.Field( - proto.MESSAGE, number=5, message="FeedOutputConfig", + proto.MESSAGE, + number=5, + message="FeedOutputConfig", + ) + condition = proto.Field( + proto.MESSAGE, + number=6, + message=expr_pb2.Expr, + ) + relationship_types = proto.RepeatedField( + proto.STRING, + number=7, ) - condition = proto.Field(proto.MESSAGE, number=6, message=expr_pb2.Expr,) - relationship_types = proto.RepeatedField(proto.STRING, number=7,) class SearchAllResourcesRequest(proto.Message): @@ -963,13 +1148,35 @@ class SearchAllResourcesRequest(proto.Message): INVALID_ARGUMENT error. """ - scope = proto.Field(proto.STRING, number=1,) - query = proto.Field(proto.STRING, number=2,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - page_size = proto.Field(proto.INT32, number=4,) - page_token = proto.Field(proto.STRING, number=5,) - order_by = proto.Field(proto.STRING, number=6,) - read_mask = proto.Field(proto.MESSAGE, number=8, message=field_mask_pb2.FieldMask,) + scope = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + page_token = proto.Field( + proto.STRING, + number=5, + ) + order_by = proto.Field( + proto.STRING, + number=6, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=8, + message=field_mask_pb2.FieldMask, + ) class SearchAllResourcesResponse(proto.Message): @@ -992,9 +1199,14 @@ def raw_page(self): return self results = proto.RepeatedField( - proto.MESSAGE, number=1, message=gca_assets.ResourceSearchResult, + proto.MESSAGE, + number=1, + message=gca_assets.ResourceSearchResult, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class SearchAllIamPoliciesRequest(proto.Message): @@ -1110,12 +1322,30 @@ class SearchAllIamPoliciesRequest(proto.Message): ``policy``) are not supported. """ - scope = proto.Field(proto.STRING, number=1,) - query = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - asset_types = proto.RepeatedField(proto.STRING, number=5,) - order_by = proto.Field(proto.STRING, number=7,) + scope = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=5, + ) + order_by = proto.Field( + proto.STRING, + number=7, + ) class SearchAllIamPoliciesResponse(proto.Message): @@ -1138,9 +1368,14 @@ def raw_page(self): return self results = proto.RepeatedField( - proto.MESSAGE, number=1, message=gca_assets.IamPolicySearchResult, + proto.MESSAGE, + number=1, + message=gca_assets.IamPolicySearchResult, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class IamPolicyAnalysisQuery(proto.Message): @@ -1190,7 +1425,10 @@ class ResourceSelector(proto.Message): types `__. """ - full_resource_name = proto.Field(proto.STRING, number=1,) + full_resource_name = proto.Field( + proto.STRING, + number=1, + ) class IdentitySelector(proto.Message): r"""Specifies an identity for which to determine resource access, @@ -1212,7 +1450,10 @@ class IdentitySelector(proto.Message): supported. You must give a specific identity. """ - identity = proto.Field(proto.STRING, number=1,) + identity = proto.Field( + proto.STRING, + number=1, + ) class AccessSelector(proto.Message): r"""Specifies roles and/or permissions to analyze, to determine @@ -1229,8 +1470,14 @@ class AccessSelector(proto.Message): result. """ - roles = proto.RepeatedField(proto.STRING, number=1,) - permissions = proto.RepeatedField(proto.STRING, number=2,) + roles = proto.RepeatedField( + proto.STRING, + number=1, + ) + permissions = proto.RepeatedField( + proto.STRING, + number=2, + ) class Options(proto.Message): r"""Contains query options. @@ -1324,12 +1571,30 @@ class Options(proto.Message): Default is false. """ - expand_groups = proto.Field(proto.BOOL, number=1,) - expand_roles = proto.Field(proto.BOOL, number=2,) - expand_resources = proto.Field(proto.BOOL, number=3,) - output_resource_edges = proto.Field(proto.BOOL, number=4,) - output_group_edges = proto.Field(proto.BOOL, number=5,) - analyze_service_account_impersonation = proto.Field(proto.BOOL, number=6,) + expand_groups = proto.Field( + proto.BOOL, + number=1, + ) + expand_roles = proto.Field( + proto.BOOL, + number=2, + ) + expand_resources = proto.Field( + proto.BOOL, + number=3, + ) + output_resource_edges = proto.Field( + proto.BOOL, + number=4, + ) + output_group_edges = proto.Field( + proto.BOOL, + number=5, + ) + analyze_service_account_impersonation = proto.Field( + proto.BOOL, + number=6, + ) class ConditionContext(proto.Message): r"""The IAM conditions context. @@ -1353,12 +1618,35 @@ class ConditionContext(proto.Message): message=timestamp_pb2.Timestamp, ) - scope = proto.Field(proto.STRING, number=1,) - resource_selector = proto.Field(proto.MESSAGE, number=2, message=ResourceSelector,) - identity_selector = proto.Field(proto.MESSAGE, number=3, message=IdentitySelector,) - access_selector = proto.Field(proto.MESSAGE, number=4, message=AccessSelector,) - options = proto.Field(proto.MESSAGE, number=5, message=Options,) - condition_context = proto.Field(proto.MESSAGE, number=6, message=ConditionContext,) + scope = proto.Field( + proto.STRING, + number=1, + ) + resource_selector = proto.Field( + proto.MESSAGE, + number=2, + message=ResourceSelector, + ) + identity_selector = proto.Field( + proto.MESSAGE, + number=3, + message=IdentitySelector, + ) + access_selector = proto.Field( + proto.MESSAGE, + number=4, + message=AccessSelector, + ) + options = proto.Field( + proto.MESSAGE, + number=5, + message=Options, + ) + condition_context = proto.Field( + proto.MESSAGE, + number=6, + message=ConditionContext, + ) class AnalyzeIamPolicyRequest(proto.Message): @@ -1384,10 +1672,14 @@ class AnalyzeIamPolicyRequest(proto.Message): """ analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", ) execution_timeout = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, ) @@ -1432,21 +1724,39 @@ class IamPolicyAnalysis(proto.Message): """ analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", ) analysis_results = proto.RepeatedField( - proto.MESSAGE, number=2, message=gca_assets.IamPolicyAnalysisResult, + proto.MESSAGE, + number=2, + message=gca_assets.IamPolicyAnalysisResult, + ) + fully_explored = proto.Field( + proto.BOOL, + number=3, ) - fully_explored = proto.Field(proto.BOOL, number=3,) non_critical_errors = proto.RepeatedField( - proto.MESSAGE, number=5, message=gca_assets.IamPolicyAnalysisState, + proto.MESSAGE, + number=5, + message=gca_assets.IamPolicyAnalysisState, ) - main_analysis = proto.Field(proto.MESSAGE, number=1, message=IamPolicyAnalysis,) + main_analysis = proto.Field( + proto.MESSAGE, + number=1, + message=IamPolicyAnalysis, + ) service_account_impersonation_analysis = proto.RepeatedField( - proto.MESSAGE, number=2, message=IamPolicyAnalysis, + proto.MESSAGE, + number=2, + message=IamPolicyAnalysis, + ) + fully_explored = proto.Field( + proto.BOOL, + number=3, ) - fully_explored = proto.Field(proto.BOOL, number=3,) class IamPolicyAnalysisOutputConfig(proto.Message): @@ -1489,7 +1799,10 @@ class GcsDestination(proto.Message): it will be overwritten with the analysis result. """ - uri = proto.Field(proto.STRING, number=1,) + uri = proto.Field( + proto.STRING, + number=1, + ) class BigQueryDestination(proto.Message): r"""A BigQuery destination. @@ -1545,20 +1858,35 @@ class PartitionKey(proto.Enum): PARTITION_KEY_UNSPECIFIED = 0 REQUEST_TIME = 1 - dataset = proto.Field(proto.STRING, number=1,) - table_prefix = proto.Field(proto.STRING, number=2,) + dataset = proto.Field( + proto.STRING, + number=1, + ) + table_prefix = proto.Field( + proto.STRING, + number=2, + ) partition_key = proto.Field( proto.ENUM, number=3, enum="IamPolicyAnalysisOutputConfig.BigQueryDestination.PartitionKey", ) - write_disposition = proto.Field(proto.STRING, number=4,) + write_disposition = proto.Field( + proto.STRING, + number=4, + ) gcs_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message=GcsDestination, + proto.MESSAGE, + number=1, + oneof="destination", + message=GcsDestination, ) bigquery_destination = proto.Field( - proto.MESSAGE, number=2, oneof="destination", message=BigQueryDestination, + proto.MESSAGE, + number=2, + oneof="destination", + message=BigQueryDestination, ) @@ -1575,10 +1903,14 @@ class AnalyzeIamPolicyLongrunningRequest(proto.Message): """ analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", ) output_config = proto.Field( - proto.MESSAGE, number=2, message="IamPolicyAnalysisOutputConfig", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisOutputConfig", ) @@ -1620,9 +1952,19 @@ class AnalysisView(proto.Enum): FULL = 1 BASIC = 2 - resource = proto.Field(proto.STRING, number=1,) - destination_parent = proto.Field(proto.STRING, number=2,) - view = proto.Field(proto.ENUM, number=3, enum=AnalysisView,) + resource = proto.Field( + proto.STRING, + number=1, + ) + destination_parent = proto.Field( + proto.STRING, + number=2, + ) + view = proto.Field( + proto.ENUM, + number=3, + enum=AnalysisView, + ) class AnalyzeMoveResponse(proto.Message): @@ -1636,7 +1978,9 @@ class AnalyzeMoveResponse(proto.Message): """ move_analysis = proto.RepeatedField( - proto.MESSAGE, number=1, message="MoveAnalysis", + proto.MESSAGE, + number=1, + message="MoveAnalysis", ) @@ -1666,12 +2010,21 @@ class MoveAnalysis(proto.Message): This field is a member of `oneof`_ ``result``. """ - display_name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field( + proto.STRING, + number=1, + ) analysis = proto.Field( - proto.MESSAGE, number=2, oneof="result", message="MoveAnalysisResult", + proto.MESSAGE, + number=2, + oneof="result", + message="MoveAnalysisResult", ) error = proto.Field( - proto.MESSAGE, number=3, oneof="result", message=status_pb2.Status, + proto.MESSAGE, + number=3, + oneof="result", + message=status_pb2.Status, ) @@ -1691,8 +2044,16 @@ class MoveAnalysisResult(proto.Message): but will not block moves at runtime. """ - blockers = proto.RepeatedField(proto.MESSAGE, number=1, message="MoveImpact",) - warnings = proto.RepeatedField(proto.MESSAGE, number=2, message="MoveImpact",) + blockers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="MoveImpact", + ) + warnings = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="MoveImpact", + ) class MoveImpact(proto.Message): @@ -1704,7 +2065,10 @@ class MoveImpact(proto.Message): message. """ - detail = proto.Field(proto.STRING, number=1,) + detail = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1/types/assets.py b/google/cloud/asset_v1/types/assets.py index 61e9c175..0e464bd4 100644 --- a/google/cloud/asset_v1/types/assets.py +++ b/google/cloud/asset_v1/types/assets.py @@ -78,11 +78,30 @@ class PriorAssetState(proto.Enum): DOES_NOT_EXIST = 3 DELETED = 4 - window = proto.Field(proto.MESSAGE, number=1, message="TimeWindow",) - deleted = proto.Field(proto.BOOL, number=2,) - asset = proto.Field(proto.MESSAGE, number=3, message="Asset",) - prior_asset_state = proto.Field(proto.ENUM, number=4, enum=PriorAssetState,) - prior_asset = proto.Field(proto.MESSAGE, number=5, message="Asset",) + window = proto.Field( + proto.MESSAGE, + number=1, + message="TimeWindow", + ) + deleted = proto.Field( + proto.BOOL, + number=2, + ) + asset = proto.Field( + proto.MESSAGE, + number=3, + message="Asset", + ) + prior_asset_state = proto.Field( + proto.ENUM, + number=4, + enum=PriorAssetState, + ) + prior_asset = proto.Field( + proto.MESSAGE, + number=5, + message="Asset", + ) class TimeWindow(proto.Message): @@ -97,8 +116,16 @@ class TimeWindow(proto.Message): instead. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) class Asset(proto.Message): @@ -194,14 +221,32 @@ class Asset(proto.Message): """ update_time = proto.Field( - proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message="Resource", + ) + iam_policy = proto.Field( + proto.MESSAGE, + number=4, + message=policy_pb2.Policy, ) - name = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message="Resource",) - iam_policy = proto.Field(proto.MESSAGE, number=4, message=policy_pb2.Policy,) org_policy = proto.RepeatedField( - proto.MESSAGE, number=6, message=orgpolicy_pb2.Policy, + proto.MESSAGE, + number=6, + message=orgpolicy_pb2.Policy, ) access_policy = proto.Field( proto.MESSAGE, @@ -221,9 +266,20 @@ class Asset(proto.Message): oneof="access_context_policy", message=service_perimeter_pb2.ServicePerimeter, ) - os_inventory = proto.Field(proto.MESSAGE, number=12, message=Inventory,) - related_assets = proto.Field(proto.MESSAGE, number=13, message="RelatedAssets",) - ancestors = proto.RepeatedField(proto.STRING, number=10,) + os_inventory = proto.Field( + proto.MESSAGE, + number=12, + message=Inventory, + ) + related_assets = proto.Field( + proto.MESSAGE, + number=13, + message="RelatedAssets", + ) + ancestors = proto.RepeatedField( + proto.STRING, + number=10, + ) class Resource(proto.Message): @@ -275,13 +331,35 @@ class Resource(proto.Message): https://cloud.google.com/about/locations/. """ - version = proto.Field(proto.STRING, number=1,) - discovery_document_uri = proto.Field(proto.STRING, number=2,) - discovery_name = proto.Field(proto.STRING, number=3,) - resource_url = proto.Field(proto.STRING, number=4,) - parent = proto.Field(proto.STRING, number=5,) - data = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Struct,) - location = proto.Field(proto.STRING, number=8,) + version = proto.Field( + proto.STRING, + number=1, + ) + discovery_document_uri = proto.Field( + proto.STRING, + number=2, + ) + discovery_name = proto.Field( + proto.STRING, + number=3, + ) + resource_url = proto.Field( + proto.STRING, + number=4, + ) + parent = proto.Field( + proto.STRING, + number=5, + ) + data = proto.Field( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) + location = proto.Field( + proto.STRING, + number=8, + ) class RelatedAssets(proto.Message): @@ -295,9 +373,15 @@ class RelatedAssets(proto.Message): """ relationship_attributes = proto.Field( - proto.MESSAGE, number=1, message="RelationshipAttributes", + proto.MESSAGE, + number=1, + message="RelationshipAttributes", + ) + assets = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="RelatedAsset", ) - assets = proto.RepeatedField(proto.MESSAGE, number=2, message="RelatedAsset",) class RelationshipAttributes(proto.Message): @@ -319,10 +403,22 @@ class RelationshipAttributes(proto.Message): ``attaches`` """ - type_ = proto.Field(proto.STRING, number=4,) - source_resource_type = proto.Field(proto.STRING, number=1,) - target_resource_type = proto.Field(proto.STRING, number=2,) - action = proto.Field(proto.STRING, number=3,) + type_ = proto.Field( + proto.STRING, + number=4, + ) + source_resource_type = proto.Field( + proto.STRING, + number=1, + ) + target_resource_type = proto.Field( + proto.STRING, + number=2, + ) + action = proto.Field( + proto.STRING, + number=3, + ) class RelatedAsset(proto.Message): @@ -362,9 +458,18 @@ class RelatedAsset(proto.Message): ``["projects/123456789", "folders/5432", "organizations/1234"]`` """ - asset = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - ancestors = proto.RepeatedField(proto.STRING, number=3,) + asset = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + ancestors = proto.RepeatedField( + proto.STRING, + number=3, + ) class ResourceSearchResult(proto.Message): @@ -612,38 +717,94 @@ class ResourceSearchResult(proto.Message): ``cloudresourcemanager.googleapis.com/Project`` """ - name = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - project = proto.Field(proto.STRING, number=3,) - folders = proto.RepeatedField(proto.STRING, number=17,) - organization = proto.Field(proto.STRING, number=18,) - display_name = proto.Field(proto.STRING, number=4,) - description = proto.Field(proto.STRING, number=5,) - location = proto.Field(proto.STRING, number=6,) - labels = proto.MapField(proto.STRING, proto.STRING, number=7,) - network_tags = proto.RepeatedField(proto.STRING, number=8,) - kms_key = proto.Field(proto.STRING, number=10,) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + project = proto.Field( + proto.STRING, + number=3, + ) + folders = proto.RepeatedField( + proto.STRING, + number=17, + ) + organization = proto.Field( + proto.STRING, + number=18, + ) + display_name = proto.Field( + proto.STRING, + number=4, + ) + description = proto.Field( + proto.STRING, + number=5, + ) + location = proto.Field( + proto.STRING, + number=6, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + network_tags = proto.RepeatedField( + proto.STRING, + number=8, + ) + kms_key = proto.Field( + proto.STRING, + number=10, + ) create_time = proto.Field( - proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, ) update_time = proto.Field( - proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=12, + message=timestamp_pb2.Timestamp, + ) + state = proto.Field( + proto.STRING, + number=13, ) - state = proto.Field(proto.STRING, number=13,) additional_attributes = proto.Field( - proto.MESSAGE, number=9, message=struct_pb2.Struct, + proto.MESSAGE, + number=9, + message=struct_pb2.Struct, + ) + parent_full_resource_name = proto.Field( + proto.STRING, + number=19, ) - parent_full_resource_name = proto.Field(proto.STRING, number=19,) versioned_resources = proto.RepeatedField( - proto.MESSAGE, number=16, message="VersionedResource", + proto.MESSAGE, + number=16, + message="VersionedResource", ) attached_resources = proto.RepeatedField( - proto.MESSAGE, number=20, message="AttachedResource", + proto.MESSAGE, + number=20, + message="AttachedResource", ) relationships = proto.MapField( - proto.STRING, proto.MESSAGE, number=21, message="RelatedResources", + proto.STRING, + proto.MESSAGE, + number=21, + message="RelatedResources", + ) + parent_asset_type = proto.Field( + proto.STRING, + number=103, ) - parent_asset_type = proto.Field(proto.STRING, number=103,) class VersionedResource(proto.Message): @@ -672,8 +833,15 @@ class VersionedResource(proto.Message): ``https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types`` """ - version = proto.Field(proto.STRING, number=1,) - resource = proto.Field(proto.MESSAGE, number=2, message=struct_pb2.Struct,) + version = proto.Field( + proto.STRING, + number=1, + ) + resource = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) class AttachedResource(proto.Message): @@ -698,9 +866,14 @@ class AttachedResource(proto.Message): migration. """ - asset_type = proto.Field(proto.STRING, number=1,) + asset_type = proto.Field( + proto.STRING, + number=1, + ) versioned_resources = proto.RepeatedField( - proto.MESSAGE, number=3, message="VersionedResource", + proto.MESSAGE, + number=3, + message="VersionedResource", ) @@ -714,7 +887,9 @@ class RelatedResources(proto.Message): """ related_resources = proto.RepeatedField( - proto.MESSAGE, number=1, message="RelatedResource", + proto.MESSAGE, + number=1, + message="RelatedResource", ) @@ -730,8 +905,14 @@ class RelatedResource(proto.Message): ``//compute.googleapis.com/projects/my_proj_123/zones/instance/instance123`` """ - asset_type = proto.Field(proto.STRING, number=1,) - full_resource_name = proto.Field(proto.STRING, number=2,) + asset_type = proto.Field( + proto.STRING, + number=1, + ) + full_resource_name = proto.Field( + proto.STRING, + number=2, + ) class IamPolicySearchResult(proto.Message): @@ -842,7 +1023,10 @@ class Permissions(proto.Message): ``compute.disk.get``. """ - permissions = proto.RepeatedField(proto.STRING, number=1,) + permissions = proto.RepeatedField( + proto.STRING, + number=1, + ) matched_permissions = proto.MapField( proto.STRING, @@ -851,13 +1035,36 @@ class Permissions(proto.Message): message="IamPolicySearchResult.Explanation.Permissions", ) - resource = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=5,) - project = proto.Field(proto.STRING, number=2,) - folders = proto.RepeatedField(proto.STRING, number=6,) - organization = proto.Field(proto.STRING, number=7,) - policy = proto.Field(proto.MESSAGE, number=3, message=policy_pb2.Policy,) - explanation = proto.Field(proto.MESSAGE, number=4, message=Explanation,) + resource = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=5, + ) + project = proto.Field( + proto.STRING, + number=2, + ) + folders = proto.RepeatedField( + proto.STRING, + number=6, + ) + organization = proto.Field( + proto.STRING, + number=7, + ) + policy = proto.Field( + proto.MESSAGE, + number=3, + message=policy_pb2.Policy, + ) + explanation = proto.Field( + proto.MESSAGE, + number=4, + message=Explanation, + ) class IamPolicyAnalysisState(proto.Message): @@ -880,8 +1087,15 @@ class IamPolicyAnalysisState(proto.Message): of failure. """ - code = proto.Field(proto.ENUM, number=1, enum=code_pb2.Code,) - cause = proto.Field(proto.STRING, number=2,) + code = proto.Field( + proto.ENUM, + number=1, + enum=code_pb2.Code, + ) + cause = proto.Field( + proto.STRING, + number=2, + ) class ConditionEvaluation(proto.Message): @@ -899,7 +1113,11 @@ class EvaluationValue(proto.Enum): FALSE = 2 CONDITIONAL = 3 - evaluation_value = proto.Field(proto.ENUM, number=1, enum=EvaluationValue,) + evaluation_value = proto.Field( + proto.ENUM, + number=1, + enum=EvaluationValue, + ) class IamPolicyAnalysisResult(proto.Message): @@ -942,9 +1160,14 @@ class Resource(proto.Message): The analysis state of this resource. """ - full_resource_name = proto.Field(proto.STRING, number=1,) + full_resource_name = proto.Field( + proto.STRING, + number=1, + ) analysis_state = proto.Field( - proto.MESSAGE, number=2, message="IamPolicyAnalysisState", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisState", ) class Access(proto.Message): @@ -970,10 +1193,20 @@ class Access(proto.Message): The analysis state of this access. """ - role = proto.Field(proto.STRING, number=1, oneof="oneof_access",) - permission = proto.Field(proto.STRING, number=2, oneof="oneof_access",) + role = proto.Field( + proto.STRING, + number=1, + oneof="oneof_access", + ) + permission = proto.Field( + proto.STRING, + number=2, + oneof="oneof_access", + ) analysis_state = proto.Field( - proto.MESSAGE, number=3, message="IamPolicyAnalysisState", + proto.MESSAGE, + number=3, + message="IamPolicyAnalysisState", ) class Identity(proto.Message): @@ -997,9 +1230,14 @@ class Identity(proto.Message): The analysis state of this identity. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) analysis_state = proto.Field( - proto.MESSAGE, number=2, message="IamPolicyAnalysisState", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisState", ) class Edge(proto.Message): @@ -1016,8 +1254,14 @@ class Edge(proto.Message): node or an email of an identity. """ - source_node = proto.Field(proto.STRING, number=1,) - target_node = proto.Field(proto.STRING, number=2,) + source_node = proto.Field( + proto.STRING, + number=1, + ) + target_node = proto.Field( + proto.STRING, + number=2, + ) class AccessControlList(proto.Message): r"""An access control list, derived from the above IAM policy binding, @@ -1068,16 +1312,24 @@ class AccessControlList(proto.Message): """ resources = proto.RepeatedField( - proto.MESSAGE, number=1, message="IamPolicyAnalysisResult.Resource", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisResult.Resource", ) accesses = proto.RepeatedField( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.Access", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.Access", ) resource_edges = proto.RepeatedField( - proto.MESSAGE, number=3, message="IamPolicyAnalysisResult.Edge", + proto.MESSAGE, + number=3, + message="IamPolicyAnalysisResult.Edge", ) condition_evaluation = proto.Field( - proto.MESSAGE, number=4, message="ConditionEvaluation", + proto.MESSAGE, + number=4, + message="ConditionEvaluation", ) class IdentityList(proto.Message): @@ -1106,19 +1358,39 @@ class IdentityList(proto.Message): """ identities = proto.RepeatedField( - proto.MESSAGE, number=1, message="IamPolicyAnalysisResult.Identity", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisResult.Identity", ) group_edges = proto.RepeatedField( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.Edge", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.Edge", ) - attached_resource_full_name = proto.Field(proto.STRING, number=1,) - iam_binding = proto.Field(proto.MESSAGE, number=2, message=policy_pb2.Binding,) + attached_resource_full_name = proto.Field( + proto.STRING, + number=1, + ) + iam_binding = proto.Field( + proto.MESSAGE, + number=2, + message=policy_pb2.Binding, + ) access_control_lists = proto.RepeatedField( - proto.MESSAGE, number=3, message=AccessControlList, + proto.MESSAGE, + number=3, + message=AccessControlList, + ) + identity_list = proto.Field( + proto.MESSAGE, + number=4, + message=IdentityList, + ) + fully_explored = proto.Field( + proto.BOOL, + number=5, ) - identity_list = proto.Field(proto.MESSAGE, number=4, message=IdentityList,) - fully_explored = proto.Field(proto.BOOL, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py index ce4f8da1..5afe3526 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py @@ -327,12 +327,20 @@ def sample_search_all_resources(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.SearchAllResourcesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -461,12 +469,20 @@ def sample_search_all_iam_policies(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.SearchAllIamPoliciesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -481,7 +497,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/client.py b/google/cloud/asset_v1p1beta1/services/asset_service/client.py index 2a782cf8..fd5b82b7 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/client.py @@ -54,7 +54,10 @@ class AssetServiceClientMeta(type): _transport_registry["grpc"] = AssetServiceGrpcTransport _transport_registry["grpc_asyncio"] = AssetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[AssetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[AssetServiceTransport]: """Returns an appropriate transport class. Args: @@ -159,7 +162,9 @@ def transport(self) -> AssetServiceTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -172,9 +177,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -183,9 +192,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -194,9 +207,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -205,10 +222,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -502,12 +523,20 @@ def sample_search_all_resources(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.SearchAllResourcesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -626,12 +655,20 @@ def sample_search_all_iam_policies(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.SearchAllIamPoliciesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -653,7 +690,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py index 5983397f..81debf27 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py @@ -29,7 +29,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -153,9 +155,9 @@ 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! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py index 4577e66b..abdb3dde 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py @@ -224,8 +224,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/asset_v1p1beta1/types/asset_service.py b/google/cloud/asset_v1p1beta1/types/asset_service.py index 4fecd5f4..16d1a602 100644 --- a/google/cloud/asset_v1p1beta1/types/asset_service.py +++ b/google/cloud/asset_v1p1beta1/types/asset_service.py @@ -70,12 +70,30 @@ class SearchAllResourcesRequest(proto.Message): example, " foo , bar desc ". """ - scope = proto.Field(proto.STRING, number=1,) - query = proto.Field(proto.STRING, number=2,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - page_size = proto.Field(proto.INT32, number=4,) - page_token = proto.Field(proto.STRING, number=5,) - order_by = proto.Field(proto.STRING, number=10,) + scope = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + page_token = proto.Field( + proto.STRING, + number=5, + ) + order_by = proto.Field( + proto.STRING, + number=10, + ) class SearchAllResourcesResponse(proto.Message): @@ -97,9 +115,14 @@ def raw_page(self): return self results = proto.RepeatedField( - proto.MESSAGE, number=1, message=assets.StandardResourceMetadata, + proto.MESSAGE, + number=1, + message=assets.StandardResourceMetadata, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class SearchAllIamPoliciesRequest(proto.Message): @@ -135,10 +158,22 @@ class SearchAllIamPoliciesRequest(proto.Message): identical to those in the previous call. """ - scope = proto.Field(proto.STRING, number=1,) - query = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + scope = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class SearchAllIamPoliciesResponse(proto.Message): @@ -161,9 +196,14 @@ def raw_page(self): return self results = proto.RepeatedField( - proto.MESSAGE, number=1, message=assets.IamPolicySearchResult, + proto.MESSAGE, + number=1, + message=assets.IamPolicySearchResult, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p1beta1/types/assets.py b/google/cloud/asset_v1p1beta1/types/assets.py index ed04df76..abb2ec24 100644 --- a/google/cloud/asset_v1p1beta1/types/assets.py +++ b/google/cloud/asset_v1p1beta1/types/assets.py @@ -20,7 +20,11 @@ __protobuf__ = proto.module( package="google.cloud.asset.v1p1beta1", - manifest={"StandardResourceMetadata", "IamPolicySearchResult", "Permissions",}, + manifest={ + "StandardResourceMetadata", + "IamPolicySearchResult", + "Permissions", + }, ) @@ -67,15 +71,43 @@ class StandardResourceMetadata(proto.Message): for more information. """ - name = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - project = proto.Field(proto.STRING, number=3,) - display_name = proto.Field(proto.STRING, number=4,) - description = proto.Field(proto.STRING, number=5,) - additional_attributes = proto.RepeatedField(proto.STRING, number=10,) - location = proto.Field(proto.STRING, number=11,) - labels = proto.MapField(proto.STRING, proto.STRING, number=12,) - network_tags = proto.RepeatedField(proto.STRING, number=13,) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + project = proto.Field( + proto.STRING, + number=3, + ) + display_name = proto.Field( + proto.STRING, + number=4, + ) + description = proto.Field( + proto.STRING, + number=5, + ) + additional_attributes = proto.RepeatedField( + proto.STRING, + number=10, + ) + location = proto.Field( + proto.STRING, + number=11, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=12, + ) + network_tags = proto.RepeatedField( + proto.STRING, + number=13, + ) class IamPolicySearchResult(proto.Message): @@ -121,13 +153,30 @@ class Explanation(proto.Message): """ matched_permissions = proto.MapField( - proto.STRING, proto.MESSAGE, number=1, message="Permissions", + proto.STRING, + proto.MESSAGE, + number=1, + message="Permissions", ) - resource = proto.Field(proto.STRING, number=1,) - project = proto.Field(proto.STRING, number=3,) - policy = proto.Field(proto.MESSAGE, number=4, message=policy_pb2.Policy,) - explanation = proto.Field(proto.MESSAGE, number=5, message=Explanation,) + resource = proto.Field( + proto.STRING, + number=1, + ) + project = proto.Field( + proto.STRING, + number=3, + ) + policy = proto.Field( + proto.MESSAGE, + number=4, + message=policy_pb2.Policy, + ) + explanation = proto.Field( + proto.MESSAGE, + number=5, + message=Explanation, + ) class Permissions(proto.Message): @@ -139,7 +188,10 @@ class Permissions(proto.Message): string: "compute.disk.get". """ - permissions = proto.RepeatedField(proto.STRING, number=1,) + permissions = proto.RepeatedField( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py index 32c171a4..a2e5f053 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py @@ -301,7 +301,12 @@ def sample_create_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -407,7 +412,12 @@ def sample_get_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -510,7 +520,12 @@ def sample_list_feeds(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -612,7 +627,12 @@ def sample_update_feed(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -705,7 +725,10 @@ def sample_delete_feed(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): @@ -717,7 +740,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/client.py b/google/cloud/asset_v1p2beta1/services/asset_service/client.py index 4c905406..077e13f8 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/client.py @@ -52,7 +52,10 @@ class AssetServiceClientMeta(type): _transport_registry["grpc"] = AssetServiceGrpcTransport _transport_registry["grpc_asyncio"] = AssetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[AssetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[AssetServiceTransport]: """Returns an appropriate transport class. Args: @@ -157,9 +160,15 @@ def transport(self) -> AssetServiceTransport: return self._transport @staticmethod - def feed_path(project: str, feed: str,) -> str: + def feed_path( + project: str, + feed: str, + ) -> str: """Returns a fully-qualified feed string.""" - return "projects/{project}/feeds/{feed}".format(project=project, feed=feed,) + return "projects/{project}/feeds/{feed}".format( + project=project, + feed=feed, + ) @staticmethod def parse_feed_path(path: str) -> Dict[str, str]: @@ -168,7 +177,9 @@ def parse_feed_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -181,9 +192,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -192,9 +207,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -203,9 +222,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -214,10 +237,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -495,7 +522,12 @@ def sample_create_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -591,7 +623,12 @@ def sample_get_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -684,7 +721,12 @@ def sample_list_feeds(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -786,7 +828,12 @@ def sample_update_feed(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -869,7 +916,10 @@ def sample_delete_feed(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): @@ -888,7 +938,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py index bc16b6fb..f2529afc 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py @@ -30,7 +30,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -120,7 +122,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_feed: gapic_v1.method.wrap_method( - self.create_feed, default_timeout=60.0, client_info=client_info, + self.create_feed, + default_timeout=60.0, + client_info=client_info, ), self.get_feed: gapic_v1.method.wrap_method( self.get_feed, @@ -153,7 +157,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.update_feed: gapic_v1.method.wrap_method( - self.update_feed, default_timeout=60.0, client_info=client_info, + self.update_feed, + default_timeout=60.0, + client_info=client_info, ), self.delete_feed: gapic_v1.method.wrap_method( self.delete_feed, @@ -175,9 +181,9 @@ 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! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py index 9896364e..2b6aac8c 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py @@ -225,8 +225,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/asset_v1p2beta1/types/asset_service.py b/google/cloud/asset_v1p2beta1/types/asset_service.py index 64fcda03..74da9252 100644 --- a/google/cloud/asset_v1p2beta1/types/asset_service.py +++ b/google/cloud/asset_v1p2beta1/types/asset_service.py @@ -69,9 +69,19 @@ class CreateFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - parent = proto.Field(proto.STRING, number=1,) - feed_id = proto.Field(proto.STRING, number=2,) - feed = proto.Field(proto.MESSAGE, number=3, message="Feed",) + parent = proto.Field( + proto.STRING, + number=1, + ) + feed_id = proto.Field( + proto.STRING, + number=2, + ) + feed = proto.Field( + proto.MESSAGE, + number=3, + message="Feed", + ) class GetFeedRequest(proto.Message): @@ -85,7 +95,10 @@ class GetFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListFeedsRequest(proto.Message): @@ -101,7 +114,10 @@ class ListFeedsRequest(proto.Message): "projects/my-project-id"). """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) class ListFeedsResponse(proto.Message): @@ -112,7 +128,11 @@ class ListFeedsResponse(proto.Message): A list of feeds. """ - feeds = proto.RepeatedField(proto.MESSAGE, number=1, message="Feed",) + feeds = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Feed", + ) class UpdateFeedRequest(proto.Message): @@ -131,9 +151,15 @@ class UpdateFeedRequest(proto.Message): contain fields that are immutable or only set by the server. """ - feed = proto.Field(proto.MESSAGE, number=1, message="Feed",) + feed = proto.Field( + proto.MESSAGE, + number=1, + message="Feed", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -148,7 +174,10 @@ class DeleteFeedRequest(proto.Message): organizations/organization_number/feeds/feed_id """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class OutputConfig(proto.Message): @@ -164,7 +193,10 @@ class OutputConfig(proto.Message): """ gcs_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message="GcsDestination", + proto.MESSAGE, + number=1, + oneof="destination", + message="GcsDestination", ) @@ -185,7 +217,11 @@ class GcsDestination(proto.Message): This field is a member of `oneof`_ ``object_uri``. """ - uri = proto.Field(proto.STRING, number=1, oneof="object_uri",) + uri = proto.Field( + proto.STRING, + number=1, + oneof="object_uri", + ) class PubsubDestination(proto.Message): @@ -197,7 +233,10 @@ class PubsubDestination(proto.Message): example: ``projects/PROJECT_ID/topics/TOPIC_ID``. """ - topic = proto.Field(proto.STRING, number=1,) + topic = proto.Field( + proto.STRING, + number=1, + ) class FeedOutputConfig(proto.Message): @@ -213,7 +252,10 @@ class FeedOutputConfig(proto.Message): """ pubsub_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message="PubsubDestination", + proto.MESSAGE, + number=1, + oneof="destination", + message="PubsubDestination", ) @@ -263,12 +305,27 @@ class Feed(proto.Message): where the asset updates are published to. """ - name = proto.Field(proto.STRING, number=1,) - asset_names = proto.RepeatedField(proto.STRING, number=2,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_names = proto.RepeatedField( + proto.STRING, + number=2, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + content_type = proto.Field( + proto.ENUM, + number=4, + enum="ContentType", + ) feed_output_config = proto.Field( - proto.MESSAGE, number=5, message="FeedOutputConfig", + proto.MESSAGE, + number=5, + message="FeedOutputConfig", ) diff --git a/google/cloud/asset_v1p2beta1/types/assets.py b/google/cloud/asset_v1p2beta1/types/assets.py index cf7791d6..97514ebe 100644 --- a/google/cloud/asset_v1p2beta1/types/assets.py +++ b/google/cloud/asset_v1p2beta1/types/assets.py @@ -22,7 +22,12 @@ __protobuf__ = proto.module( package="google.cloud.asset.v1p2beta1", - manifest={"TemporalAsset", "TimeWindow", "Asset", "Resource",}, + manifest={ + "TemporalAsset", + "TimeWindow", + "Asset", + "Resource", + }, ) @@ -41,9 +46,20 @@ class TemporalAsset(proto.Message): Asset. """ - window = proto.Field(proto.MESSAGE, number=1, message="TimeWindow",) - deleted = proto.Field(proto.BOOL, number=2,) - asset = proto.Field(proto.MESSAGE, number=3, message="Asset",) + window = proto.Field( + proto.MESSAGE, + number=1, + message="TimeWindow", + ) + deleted = proto.Field( + proto.BOOL, + number=2, + ) + asset = proto.Field( + proto.MESSAGE, + number=3, + message="Asset", + ) class TimeWindow(proto.Message): @@ -57,8 +73,16 @@ class TimeWindow(proto.Message): Current timestamp if not specified. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) class Asset(proto.Message): @@ -93,11 +117,28 @@ class Asset(proto.Message): "organizations/1234"] """ - name = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message="Resource",) - iam_policy = proto.Field(proto.MESSAGE, number=4, message=policy_pb2.Policy,) - ancestors = proto.RepeatedField(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message="Resource", + ) + iam_policy = proto.Field( + proto.MESSAGE, + number=4, + message=policy_pb2.Policy, + ) + ancestors = proto.RepeatedField( + proto.STRING, + number=6, + ) class Resource(proto.Message): @@ -143,12 +184,31 @@ class Resource(proto.Message): be present. """ - version = proto.Field(proto.STRING, number=1,) - discovery_document_uri = proto.Field(proto.STRING, number=2,) - discovery_name = proto.Field(proto.STRING, number=3,) - resource_url = proto.Field(proto.STRING, number=4,) - parent = proto.Field(proto.STRING, number=5,) - data = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Struct,) + version = proto.Field( + proto.STRING, + number=1, + ) + discovery_document_uri = proto.Field( + proto.STRING, + number=2, + ) + discovery_name = proto.Field( + proto.STRING, + number=3, + ) + resource_url = proto.Field( + proto.STRING, + number=4, + ) + parent = proto.Field( + proto.STRING, + number=5, + ) + data = proto.Field( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py index 8240dfef..039c5893 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py @@ -279,7 +279,12 @@ def sample_analyze_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -369,7 +374,12 @@ def sample_export_iam_policy_analysis(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -391,7 +401,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/client.py b/google/cloud/asset_v1p4beta1/services/asset_service/client.py index feefa82d..4a4f7013 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/client.py @@ -55,7 +55,10 @@ class AssetServiceClientMeta(type): _transport_registry["grpc"] = AssetServiceGrpcTransport _transport_registry["grpc_asyncio"] = AssetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[AssetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[AssetServiceTransport]: """Returns an appropriate transport class. Args: @@ -160,7 +163,9 @@ def transport(self) -> AssetServiceTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -173,9 +178,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -184,9 +193,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -195,9 +208,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -206,10 +223,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -456,7 +477,12 @@ def sample_analyze_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -549,7 +575,12 @@ def sample_export_iam_policy_analysis(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -578,7 +609,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py index eebdaa0a..3bd030c6 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py @@ -31,7 +31,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -144,9 +146,9 @@ 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! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py index 333d88da..ab75d3c7 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py @@ -227,8 +227,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/asset_v1p4beta1/types/asset_service.py b/google/cloud/asset_v1p4beta1/types/asset_service.py index 021dd41a..92c0f463 100644 --- a/google/cloud/asset_v1p4beta1/types/asset_service.py +++ b/google/cloud/asset_v1p4beta1/types/asset_service.py @@ -71,7 +71,10 @@ class ResourceSelector(proto.Message): . """ - full_resource_name = proto.Field(proto.STRING, number=1,) + full_resource_name = proto.Field( + proto.STRING, + number=1, + ) class IdentitySelector(proto.Message): r"""Specifies an identity for which to determine resource access, @@ -85,7 +88,10 @@ class IdentitySelector(proto.Message): binding `__. """ - identity = proto.Field(proto.STRING, number=1,) + identity = proto.Field( + proto.STRING, + number=1, + ) class AccessSelector(proto.Message): r"""Specifies roles and/or permissions to analyze, to determine @@ -101,13 +107,34 @@ class AccessSelector(proto.Message): result. """ - roles = proto.RepeatedField(proto.STRING, number=1,) - permissions = proto.RepeatedField(proto.STRING, number=2,) + roles = proto.RepeatedField( + proto.STRING, + number=1, + ) + permissions = proto.RepeatedField( + proto.STRING, + number=2, + ) - parent = proto.Field(proto.STRING, number=1,) - resource_selector = proto.Field(proto.MESSAGE, number=2, message=ResourceSelector,) - identity_selector = proto.Field(proto.MESSAGE, number=3, message=IdentitySelector,) - access_selector = proto.Field(proto.MESSAGE, number=4, message=AccessSelector,) + parent = proto.Field( + proto.STRING, + number=1, + ) + resource_selector = proto.Field( + proto.MESSAGE, + number=2, + message=ResourceSelector, + ) + identity_selector = proto.Field( + proto.MESSAGE, + number=3, + message=IdentitySelector, + ) + access_selector = proto.Field( + proto.MESSAGE, + number=4, + message=AccessSelector, + ) class AnalyzeIamPolicyRequest(proto.Message): @@ -208,20 +235,46 @@ class Options(proto.Message): Default is empty. """ - expand_groups = proto.Field(proto.BOOL, number=1,) - expand_roles = proto.Field(proto.BOOL, number=2,) - expand_resources = proto.Field(proto.BOOL, number=3,) - output_resource_edges = proto.Field(proto.BOOL, number=4,) - output_group_edges = proto.Field(proto.BOOL, number=5,) - analyze_service_account_impersonation = proto.Field(proto.BOOL, number=6,) + expand_groups = proto.Field( + proto.BOOL, + number=1, + ) + expand_roles = proto.Field( + proto.BOOL, + number=2, + ) + expand_resources = proto.Field( + proto.BOOL, + number=3, + ) + output_resource_edges = proto.Field( + proto.BOOL, + number=4, + ) + output_group_edges = proto.Field( + proto.BOOL, + number=5, + ) + analyze_service_account_impersonation = proto.Field( + proto.BOOL, + number=6, + ) execution_timeout = proto.Field( - proto.MESSAGE, number=7, message=duration_pb2.Duration, + proto.MESSAGE, + number=7, + message=duration_pb2.Duration, ) analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", + ) + options = proto.Field( + proto.MESSAGE, + number=2, + message=Options, ) - options = proto.Field(proto.MESSAGE, number=2, message=Options,) class AnalyzeIamPolicyResponse(proto.Message): @@ -266,20 +319,38 @@ class IamPolicyAnalysis(proto.Message): """ analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", ) analysis_results = proto.RepeatedField( - proto.MESSAGE, number=2, message=assets.IamPolicyAnalysisResult, + proto.MESSAGE, + number=2, + message=assets.IamPolicyAnalysisResult, + ) + fully_explored = proto.Field( + proto.BOOL, + number=3, ) - fully_explored = proto.Field(proto.BOOL, number=3,) - main_analysis = proto.Field(proto.MESSAGE, number=1, message=IamPolicyAnalysis,) + main_analysis = proto.Field( + proto.MESSAGE, + number=1, + message=IamPolicyAnalysis, + ) service_account_impersonation_analysis = proto.RepeatedField( - proto.MESSAGE, number=2, message=IamPolicyAnalysis, + proto.MESSAGE, + number=2, + message=IamPolicyAnalysis, + ) + fully_explored = proto.Field( + proto.BOOL, + number=3, ) - fully_explored = proto.Field(proto.BOOL, number=3,) non_critical_errors = proto.RepeatedField( - proto.MESSAGE, number=4, message=assets.IamPolicyAnalysisResult.AnalysisState, + proto.MESSAGE, + number=4, + message=assets.IamPolicyAnalysisResult.AnalysisState, ) @@ -310,10 +381,16 @@ class GcsDestination(proto.Message): for more information. """ - uri = proto.Field(proto.STRING, number=1,) + uri = proto.Field( + proto.STRING, + number=1, + ) gcs_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message=GcsDestination, + proto.MESSAGE, + number=1, + oneof="destination", + message=GcsDestination, ) @@ -404,19 +481,45 @@ class Options(proto.Message): Default is false. """ - expand_groups = proto.Field(proto.BOOL, number=1,) - expand_roles = proto.Field(proto.BOOL, number=2,) - expand_resources = proto.Field(proto.BOOL, number=3,) - output_resource_edges = proto.Field(proto.BOOL, number=4,) - output_group_edges = proto.Field(proto.BOOL, number=5,) - analyze_service_account_impersonation = proto.Field(proto.BOOL, number=6,) + expand_groups = proto.Field( + proto.BOOL, + number=1, + ) + expand_roles = proto.Field( + proto.BOOL, + number=2, + ) + expand_resources = proto.Field( + proto.BOOL, + number=3, + ) + output_resource_edges = proto.Field( + proto.BOOL, + number=4, + ) + output_group_edges = proto.Field( + proto.BOOL, + number=5, + ) + analyze_service_account_impersonation = proto.Field( + proto.BOOL, + number=6, + ) analysis_query = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisQuery", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisQuery", + ) + options = proto.Field( + proto.MESSAGE, + number=2, + message=Options, ) - options = proto.Field(proto.MESSAGE, number=2, message=Options,) output_config = proto.Field( - proto.MESSAGE, number=3, message="IamPolicyAnalysisOutputConfig", + proto.MESSAGE, + number=3, + message="IamPolicyAnalysisOutputConfig", ) @@ -432,7 +535,9 @@ class ExportIamPolicyAnalysisResponse(proto.Message): """ output_config = proto.Field( - proto.MESSAGE, number=1, message="IamPolicyAnalysisOutputConfig", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisOutputConfig", ) diff --git a/google/cloud/asset_v1p4beta1/types/assets.py b/google/cloud/asset_v1p4beta1/types/assets.py index e7ffb3db..a2feac1e 100644 --- a/google/cloud/asset_v1p4beta1/types/assets.py +++ b/google/cloud/asset_v1p4beta1/types/assets.py @@ -20,7 +20,10 @@ __protobuf__ = proto.module( - package="google.cloud.asset.v1p4beta1", manifest={"IamPolicyAnalysisResult",}, + package="google.cloud.asset.v1p4beta1", + manifest={ + "IamPolicyAnalysisResult", + }, ) @@ -71,8 +74,15 @@ class AnalysisState(proto.Message): of failure. """ - code = proto.Field(proto.ENUM, number=1, enum=code_pb2.Code,) - cause = proto.Field(proto.STRING, number=2,) + code = proto.Field( + proto.ENUM, + number=1, + enum=code_pb2.Code, + ) + cause = proto.Field( + proto.STRING, + number=2, + ) class Resource(proto.Message): r"""A GCP resource that appears in an access control list. @@ -85,9 +95,14 @@ class Resource(proto.Message): The analysis state of this resource node. """ - full_resource_name = proto.Field(proto.STRING, number=1,) + full_resource_name = proto.Field( + proto.STRING, + number=1, + ) analysis_state = proto.Field( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.AnalysisState", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.AnalysisState", ) class Access(proto.Message): @@ -113,10 +128,20 @@ class Access(proto.Message): The analysis state of this access node. """ - role = proto.Field(proto.STRING, number=1, oneof="oneof_access",) - permission = proto.Field(proto.STRING, number=2, oneof="oneof_access",) + role = proto.Field( + proto.STRING, + number=1, + oneof="oneof_access", + ) + permission = proto.Field( + proto.STRING, + number=2, + oneof="oneof_access", + ) analysis_state = proto.Field( - proto.MESSAGE, number=3, message="IamPolicyAnalysisResult.AnalysisState", + proto.MESSAGE, + number=3, + message="IamPolicyAnalysisResult.AnalysisState", ) class Edge(proto.Message): @@ -129,8 +154,14 @@ class Edge(proto.Message): The target node of the edge. """ - source_node = proto.Field(proto.STRING, number=1,) - target_node = proto.Field(proto.STRING, number=2,) + source_node = proto.Field( + proto.STRING, + number=1, + ) + target_node = proto.Field( + proto.STRING, + number=2, + ) class Identity(proto.Message): r"""An identity that appears in an access control list. @@ -153,9 +184,14 @@ class Identity(proto.Message): The analysis state of this identity node. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) analysis_state = proto.Field( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.AnalysisState", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.AnalysisState", ) class AccessControlList(proto.Message): @@ -203,13 +239,19 @@ class AccessControlList(proto.Message): """ resources = proto.RepeatedField( - proto.MESSAGE, number=1, message="IamPolicyAnalysisResult.Resource", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisResult.Resource", ) accesses = proto.RepeatedField( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.Access", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.Access", ) resource_edges = proto.RepeatedField( - proto.MESSAGE, number=3, message="IamPolicyAnalysisResult.Edge", + proto.MESSAGE, + number=3, + message="IamPolicyAnalysisResult.Edge", ) class IdentityList(proto.Message): @@ -238,19 +280,39 @@ class IdentityList(proto.Message): """ identities = proto.RepeatedField( - proto.MESSAGE, number=1, message="IamPolicyAnalysisResult.Identity", + proto.MESSAGE, + number=1, + message="IamPolicyAnalysisResult.Identity", ) group_edges = proto.RepeatedField( - proto.MESSAGE, number=2, message="IamPolicyAnalysisResult.Edge", + proto.MESSAGE, + number=2, + message="IamPolicyAnalysisResult.Edge", ) - attached_resource_full_name = proto.Field(proto.STRING, number=1,) - iam_binding = proto.Field(proto.MESSAGE, number=2, message=policy_pb2.Binding,) + attached_resource_full_name = proto.Field( + proto.STRING, + number=1, + ) + iam_binding = proto.Field( + proto.MESSAGE, + number=2, + message=policy_pb2.Binding, + ) access_control_lists = proto.RepeatedField( - proto.MESSAGE, number=3, message=AccessControlList, + proto.MESSAGE, + number=3, + message=AccessControlList, + ) + identity_list = proto.Field( + proto.MESSAGE, + number=4, + message=IdentityList, + ) + fully_explored = proto.Field( + proto.BOOL, + number=5, ) - identity_list = proto.Field(proto.MESSAGE, number=4, message=IdentityList,) - fully_explored = proto.Field(proto.BOOL, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index feb60f77..0c8879e4 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py @@ -284,12 +284,20 @@ def sample_list_assets(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListAssetsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -304,7 +312,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/client.py b/google/cloud/asset_v1p5beta1/services/asset_service/client.py index fa01fbd7..983acd35 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/client.py @@ -54,7 +54,10 @@ class AssetServiceClientMeta(type): _transport_registry["grpc"] = AssetServiceGrpcTransport _transport_registry["grpc_asyncio"] = AssetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[AssetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[AssetServiceTransport]: """Returns an appropriate transport class. Args: @@ -159,10 +162,14 @@ def transport(self) -> AssetServiceTransport: return self._transport @staticmethod - def access_level_path(access_policy: str, access_level: str,) -> str: + def access_level_path( + access_policy: str, + access_level: str, + ) -> str: """Returns a fully-qualified access_level string.""" return "accessPolicies/{access_policy}/accessLevels/{access_level}".format( - access_policy=access_policy, access_level=access_level, + access_policy=access_policy, + access_level=access_level, ) @staticmethod @@ -175,9 +182,13 @@ def parse_access_level_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def access_policy_path(access_policy: str,) -> str: + def access_policy_path( + access_policy: str, + ) -> str: """Returns a fully-qualified access_policy string.""" - return "accessPolicies/{access_policy}".format(access_policy=access_policy,) + return "accessPolicies/{access_policy}".format( + access_policy=access_policy, + ) @staticmethod def parse_access_policy_path(path: str) -> Dict[str, str]: @@ -191,10 +202,14 @@ def asset_path() -> str: return "*".format() @staticmethod - def service_perimeter_path(access_policy: str, service_perimeter: str,) -> str: + def service_perimeter_path( + access_policy: str, + service_perimeter: str, + ) -> str: """Returns a fully-qualified service_perimeter string.""" return "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( - access_policy=access_policy, service_perimeter=service_perimeter, + access_policy=access_policy, + service_perimeter=service_perimeter, ) @staticmethod @@ -207,7 +222,9 @@ def parse_service_perimeter_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -220,9 +237,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -231,9 +252,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -242,9 +267,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -253,10 +282,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -498,12 +531,20 @@ def sample_list_assets(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListAssetsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -525,7 +566,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py index 125ee3f8..3123ad4b 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py @@ -29,7 +29,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-asset", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -138,9 +140,9 @@ 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! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py index 3efedfdc..85eb92a9 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py @@ -224,8 +224,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/asset_v1p5beta1/types/asset_service.py b/google/cloud/asset_v1p5beta1/types/asset_service.py index cefe2637..1f15df80 100644 --- a/google/cloud/asset_v1p5beta1/types/asset_service.py +++ b/google/cloud/asset_v1p5beta1/types/asset_service.py @@ -21,7 +21,11 @@ __protobuf__ = proto.module( package="google.cloud.asset.v1p5beta1", - manifest={"ContentType", "ListAssetsRequest", "ListAssetsResponse",}, + manifest={ + "ContentType", + "ListAssetsRequest", + "ListAssetsResponse", + }, ) @@ -74,12 +78,32 @@ class ListAssetsRequest(proto.Message): of assets. """ - parent = proto.Field(proto.STRING, number=1,) - read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - asset_types = proto.RepeatedField(proto.STRING, number=3,) - content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) - page_size = proto.Field(proto.INT32, number=5,) - page_token = proto.Field(proto.STRING, number=6,) + parent = proto.Field( + proto.STRING, + number=1, + ) + read_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + asset_types = proto.RepeatedField( + proto.STRING, + number=3, + ) + content_type = proto.Field( + proto.ENUM, + number=4, + enum="ContentType", + ) + page_size = proto.Field( + proto.INT32, + number=5, + ) + page_token = proto.Field( + proto.STRING, + number=6, + ) class ListAssetsResponse(proto.Message): @@ -99,9 +123,20 @@ class ListAssetsResponse(proto.Message): def raw_page(self): return self - read_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - assets = proto.RepeatedField(proto.MESSAGE, number=2, message=gca_assets.Asset,) - next_page_token = proto.Field(proto.STRING, number=3,) + read_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + assets = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gca_assets.Asset, + ) + next_page_token = proto.Field( + proto.STRING, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1p5beta1/types/assets.py b/google/cloud/asset_v1p5beta1/types/assets.py index 18203a95..5399b2c8 100644 --- a/google/cloud/asset_v1p5beta1/types/assets.py +++ b/google/cloud/asset_v1p5beta1/types/assets.py @@ -24,7 +24,11 @@ __protobuf__ = proto.module( - package="google.cloud.asset.v1p5beta1", manifest={"Asset", "Resource",}, + package="google.cloud.asset.v1p5beta1", + manifest={ + "Asset", + "Resource", + }, ) @@ -81,12 +85,28 @@ class Asset(proto.Message): "organizations/1234"] """ - name = proto.Field(proto.STRING, number=1,) - asset_type = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message="Resource",) - iam_policy = proto.Field(proto.MESSAGE, number=4, message=policy_pb2.Policy,) + name = proto.Field( + proto.STRING, + number=1, + ) + asset_type = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message="Resource", + ) + iam_policy = proto.Field( + proto.MESSAGE, + number=4, + message=policy_pb2.Policy, + ) org_policy = proto.RepeatedField( - proto.MESSAGE, number=6, message=orgpolicy_pb2.Policy, + proto.MESSAGE, + number=6, + message=orgpolicy_pb2.Policy, ) access_policy = proto.Field( proto.MESSAGE, @@ -106,7 +126,10 @@ class Asset(proto.Message): oneof="access_context_policy", message=service_perimeter_pb2.ServicePerimeter, ) - ancestors = proto.RepeatedField(proto.STRING, number=10,) + ancestors = proto.RepeatedField( + proto.STRING, + number=10, + ) class Resource(proto.Message): @@ -152,12 +175,31 @@ class Resource(proto.Message): be present. """ - version = proto.Field(proto.STRING, number=1,) - discovery_document_uri = proto.Field(proto.STRING, number=2,) - discovery_name = proto.Field(proto.STRING, number=3,) - resource_url = proto.Field(proto.STRING, number=4,) - parent = proto.Field(proto.STRING, number=5,) - data = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Struct,) + version = proto.Field( + proto.STRING, + number=1, + ) + discovery_document_uri = proto.Field( + proto.STRING, + number=2, + ) + discovery_name = proto.Field( + proto.STRING, + number=3, + ) + resource_url = proto.Field( + proto.STRING, + number=4, + ) + parent = proto.Field( + proto.STRING, + number=5, + ) + data = proto.Field( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 4cc0734e..58935cad 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 4c808af7..949e0fde 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. diff --git a/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/unit/gapic/asset_v1/test_asset_service.py index 76997532..a9a6632a 100644 --- a/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1/test_asset_service.py @@ -91,7 +91,13 @@ def test__get_default_mtls_endpoint(): assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -131,7 +137,13 @@ def test_asset_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -486,7 +498,9 @@ def test_asset_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -624,10 +638,17 @@ def test_asset_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [asset_service.ExportAssetsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ExportAssetsRequest, + dict, + ], +) def test_export_assets(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -653,7 +674,8 @@ def test_export_assets_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -669,7 +691,8 @@ async def test_export_assets_async( transport: str = "grpc_asyncio", request_type=asset_service.ExportAssetsRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -699,7 +722,9 @@ async def test_export_assets_async_from_dict(): def test_export_assets_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -719,12 +744,17 @@ def test_export_assets_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_export_assets_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -746,13 +776,23 @@ async def test_export_assets_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [asset_service.ListAssetsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ListAssetsRequest, + dict, + ], +) def test_list_assets(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -781,7 +821,8 @@ def test_list_assets_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -797,7 +838,8 @@ async def test_list_assets_async( transport: str = "grpc_asyncio", request_type=asset_service.ListAssetsRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -808,7 +850,9 @@ async def test_list_assets_async( with mock.patch.object(type(client.transport.list_assets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - asset_service.ListAssetsResponse(next_page_token="next_page_token_value",) + asset_service.ListAssetsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_assets(request) @@ -828,7 +872,9 @@ async def test_list_assets_async_from_dict(): def test_list_assets_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -848,12 +894,17 @@ def test_list_assets_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_assets_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -875,11 +926,16 @@ async def test_list_assets_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_assets_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assets), "__call__") as call: @@ -887,7 +943,9 @@ def test_list_assets_flattened(): call.return_value = asset_service.ListAssetsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_assets(parent="parent_value",) + client.list_assets( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -899,19 +957,24 @@ def test_list_assets_flattened(): def test_list_assets_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_assets( - asset_service.ListAssetsRequest(), parent="parent_value", + asset_service.ListAssetsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_assets_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assets), "__call__") as call: @@ -923,7 +986,9 @@ async def test_list_assets_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_assets(parent="parent_value",) + response = await client.list_assets( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -936,19 +1001,23 @@ async def test_list_assets_flattened_async(): @pytest.mark.asyncio async def test_list_assets_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_assets( - asset_service.ListAssetsRequest(), parent="parent_value", + asset_service.ListAssetsRequest(), + parent="parent_value", ) def test_list_assets_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -956,14 +1025,29 @@ def test_list_assets_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) @@ -982,7 +1066,8 @@ def test_list_assets_pager(transport_name: str = "grpc"): def test_list_assets_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -990,14 +1075,29 @@ def test_list_assets_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) pages = list(client.list_assets(request={}).pages) @@ -1007,7 +1107,9 @@ def test_list_assets_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_assets_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1016,17 +1118,34 @@ async def test_list_assets_async_pager(): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) - async_pager = await client.list_assets(request={},) + async_pager = await client.list_assets( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1038,7 +1157,9 @@ async def test_list_assets_async_pager(): @pytest.mark.asyncio async def test_list_assets_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1047,14 +1168,29 @@ async def test_list_assets_async_pages(): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) pages = [] @@ -1065,11 +1201,16 @@ async def test_list_assets_async_pages(): @pytest.mark.parametrize( - "request_type", [asset_service.BatchGetAssetsHistoryRequest, dict,] + "request_type", + [ + asset_service.BatchGetAssetsHistoryRequest, + dict, + ], ) def test_batch_get_assets_history(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1097,7 +1238,8 @@ def test_batch_get_assets_history_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1116,7 +1258,8 @@ async def test_batch_get_assets_history_async( request_type=asset_service.BatchGetAssetsHistoryRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1148,7 +1291,9 @@ async def test_batch_get_assets_history_async_from_dict(): def test_batch_get_assets_history_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1170,12 +1315,17 @@ def test_batch_get_assets_history_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_batch_get_assets_history_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1199,13 +1349,23 @@ async def test_batch_get_assets_history_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [asset_service.CreateFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.CreateFeedRequest, + dict, + ], +) def test_create_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1242,7 +1402,8 @@ def test_create_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1258,7 +1419,8 @@ async def test_create_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.CreateFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1299,7 +1461,9 @@ async def test_create_feed_async_from_dict(): def test_create_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1319,12 +1483,17 @@ def test_create_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1344,11 +1513,16 @@ async def test_create_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feed), "__call__") as call: @@ -1356,7 +1530,9 @@ def test_create_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_feed(parent="parent_value",) + client.create_feed( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1368,19 +1544,24 @@ def test_create_feed_flattened(): def test_create_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.create_feed( - asset_service.CreateFeedRequest(), parent="parent_value", + asset_service.CreateFeedRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_create_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feed), "__call__") as call: @@ -1390,7 +1571,9 @@ async def test_create_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_feed(parent="parent_value",) + response = await client.create_feed( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1403,20 +1586,30 @@ async def test_create_feed_flattened_async(): @pytest.mark.asyncio async def test_create_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_feed( - asset_service.CreateFeedRequest(), parent="parent_value", + asset_service.CreateFeedRequest(), + parent="parent_value", ) -@pytest.mark.parametrize("request_type", [asset_service.GetFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.GetFeedRequest, + dict, + ], +) def test_get_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1453,7 +1646,8 @@ def test_get_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1469,7 +1663,8 @@ async def test_get_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.GetFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1510,7 +1705,9 @@ async def test_get_feed_async_from_dict(): def test_get_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1530,12 +1727,17 @@ def test_get_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1555,11 +1757,16 @@ async def test_get_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feed), "__call__") as call: @@ -1567,7 +1774,9 @@ def test_get_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_feed(name="name_value",) + client.get_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1579,19 +1788,24 @@ def test_get_feed_flattened(): def test_get_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_feed( - asset_service.GetFeedRequest(), name="name_value", + asset_service.GetFeedRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feed), "__call__") as call: @@ -1601,7 +1815,9 @@ async def test_get_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_feed(name="name_value",) + response = await client.get_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1614,20 +1830,30 @@ async def test_get_feed_flattened_async(): @pytest.mark.asyncio async def test_get_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_feed( - asset_service.GetFeedRequest(), name="name_value", + asset_service.GetFeedRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [asset_service.ListFeedsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ListFeedsRequest, + dict, + ], +) def test_list_feeds(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1653,7 +1879,8 @@ def test_list_feeds_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1669,7 +1896,8 @@ async def test_list_feeds_async( transport: str = "grpc_asyncio", request_type=asset_service.ListFeedsRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1699,7 +1927,9 @@ async def test_list_feeds_async_from_dict(): def test_list_feeds_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1719,12 +1949,17 @@ def test_list_feeds_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_feeds_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1746,11 +1981,16 @@ async def test_list_feeds_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_feeds_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_feeds), "__call__") as call: @@ -1758,7 +1998,9 @@ def test_list_feeds_flattened(): call.return_value = asset_service.ListFeedsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_feeds(parent="parent_value",) + client.list_feeds( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1770,19 +2012,24 @@ def test_list_feeds_flattened(): def test_list_feeds_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_feeds( - asset_service.ListFeedsRequest(), parent="parent_value", + asset_service.ListFeedsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_feeds_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_feeds), "__call__") as call: @@ -1794,7 +2041,9 @@ async def test_list_feeds_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_feeds(parent="parent_value",) + response = await client.list_feeds( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1807,20 +2056,30 @@ async def test_list_feeds_flattened_async(): @pytest.mark.asyncio async def test_list_feeds_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_feeds( - asset_service.ListFeedsRequest(), parent="parent_value", + asset_service.ListFeedsRequest(), + parent="parent_value", ) -@pytest.mark.parametrize("request_type", [asset_service.UpdateFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.UpdateFeedRequest, + dict, + ], +) def test_update_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1857,7 +2116,8 @@ def test_update_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1873,7 +2133,8 @@ async def test_update_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.UpdateFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1914,7 +2175,9 @@ async def test_update_feed_async_from_dict(): def test_update_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1934,12 +2197,17 @@ def test_update_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "feed.name=feed.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "feed.name=feed.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1959,11 +2227,16 @@ async def test_update_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "feed.name=feed.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "feed.name=feed.name/value", + ) in kw["metadata"] def test_update_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -1971,7 +2244,9 @@ def test_update_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_feed(feed=asset_service.Feed(name="name_value"),) + client.update_feed( + feed=asset_service.Feed(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1983,7 +2258,9 @@ def test_update_feed_flattened(): def test_update_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1996,7 +2273,9 @@ def test_update_feed_flattened_error(): @pytest.mark.asyncio async def test_update_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -2006,7 +2285,9 @@ async def test_update_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_feed(feed=asset_service.Feed(name="name_value"),) + response = await client.update_feed( + feed=asset_service.Feed(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -2019,7 +2300,9 @@ async def test_update_feed_flattened_async(): @pytest.mark.asyncio async def test_update_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2030,10 +2313,17 @@ async def test_update_feed_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [asset_service.DeleteFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.DeleteFeedRequest, + dict, + ], +) def test_delete_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2059,7 +2349,8 @@ def test_delete_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2075,7 +2366,8 @@ async def test_delete_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.DeleteFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2103,7 +2395,9 @@ async def test_delete_feed_async_from_dict(): def test_delete_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -2123,12 +2417,17 @@ def test_delete_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -2148,11 +2447,16 @@ async def test_delete_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feed), "__call__") as call: @@ -2160,7 +2464,9 @@ def test_delete_feed_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_feed(name="name_value",) + client.delete_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2172,19 +2478,24 @@ def test_delete_feed_flattened(): def test_delete_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_feed( - asset_service.DeleteFeedRequest(), name="name_value", + asset_service.DeleteFeedRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feed), "__call__") as call: @@ -2194,7 +2505,9 @@ async def test_delete_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_feed(name="name_value",) + response = await client.delete_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2207,22 +2520,30 @@ async def test_delete_feed_flattened_async(): @pytest.mark.asyncio async def test_delete_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_feed( - asset_service.DeleteFeedRequest(), name="name_value", + asset_service.DeleteFeedRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [asset_service.SearchAllResourcesRequest, dict,] + "request_type", + [ + asset_service.SearchAllResourcesRequest, + dict, + ], ) def test_search_all_resources(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2253,7 +2574,8 @@ def test_search_all_resources_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2272,7 +2594,8 @@ async def test_search_all_resources_async( request_type=asset_service.SearchAllResourcesRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2307,7 +2630,9 @@ async def test_search_all_resources_async_from_dict(): def test_search_all_resources_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -2329,12 +2654,17 @@ def test_search_all_resources_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_search_all_resources_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -2358,11 +2688,16 @@ async def test_search_all_resources_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] def test_search_all_resources_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2373,7 +2708,9 @@ def test_search_all_resources_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_all_resources( - scope="scope_value", query="query_value", asset_types=["asset_types_value"], + scope="scope_value", + query="query_value", + asset_types=["asset_types_value"], ) # Establish that the underlying call was made with the expected @@ -2392,7 +2729,9 @@ def test_search_all_resources_flattened(): def test_search_all_resources_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2407,7 +2746,9 @@ def test_search_all_resources_flattened_error(): @pytest.mark.asyncio async def test_search_all_resources_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2422,7 +2763,9 @@ async def test_search_all_resources_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_all_resources( - scope="scope_value", query="query_value", asset_types=["asset_types_value"], + scope="scope_value", + query="query_value", + asset_types=["asset_types_value"], ) # Establish that the underlying call was made with the expected @@ -2442,7 +2785,9 @@ async def test_search_all_resources_flattened_async(): @pytest.mark.asyncio async def test_search_all_resources_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2457,7 +2802,8 @@ async def test_search_all_resources_flattened_error_async(): def test_search_all_resources_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2475,13 +2821,20 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(),], next_page_token="ghi", + results=[ + assets.ResourceSearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(), assets.ResourceSearchResult(),], + results=[ + assets.ResourceSearchResult(), + assets.ResourceSearchResult(), + ], ), RuntimeError, ) @@ -2501,7 +2854,8 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): def test_search_all_resources_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2519,13 +2873,20 @@ def test_search_all_resources_pages(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(),], next_page_token="ghi", + results=[ + assets.ResourceSearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(), assets.ResourceSearchResult(),], + results=[ + assets.ResourceSearchResult(), + assets.ResourceSearchResult(), + ], ), RuntimeError, ) @@ -2536,7 +2897,9 @@ def test_search_all_resources_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_search_all_resources_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2555,17 +2918,26 @@ async def test_search_all_resources_async_pager(): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(),], next_page_token="ghi", + results=[ + assets.ResourceSearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(), assets.ResourceSearchResult(),], + results=[ + assets.ResourceSearchResult(), + assets.ResourceSearchResult(), + ], ), RuntimeError, ) - async_pager = await client.search_all_resources(request={},) + async_pager = await client.search_all_resources( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2577,7 +2949,9 @@ async def test_search_all_resources_async_pager(): @pytest.mark.asyncio async def test_search_all_resources_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2596,13 +2970,20 @@ async def test_search_all_resources_async_pages(): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(),], next_page_token="ghi", + results=[ + assets.ResourceSearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( - results=[assets.ResourceSearchResult(), assets.ResourceSearchResult(),], + results=[ + assets.ResourceSearchResult(), + assets.ResourceSearchResult(), + ], ), RuntimeError, ) @@ -2614,11 +2995,16 @@ async def test_search_all_resources_async_pages(): @pytest.mark.parametrize( - "request_type", [asset_service.SearchAllIamPoliciesRequest, dict,] + "request_type", + [ + asset_service.SearchAllIamPoliciesRequest, + dict, + ], ) def test_search_all_iam_policies(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2649,7 +3035,8 @@ def test_search_all_iam_policies_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2668,7 +3055,8 @@ async def test_search_all_iam_policies_async( request_type=asset_service.SearchAllIamPoliciesRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2703,7 +3091,9 @@ async def test_search_all_iam_policies_async_from_dict(): def test_search_all_iam_policies_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -2725,12 +3115,17 @@ def test_search_all_iam_policies_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_search_all_iam_policies_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -2754,11 +3149,16 @@ async def test_search_all_iam_policies_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] def test_search_all_iam_policies_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2769,7 +3169,8 @@ def test_search_all_iam_policies_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_all_iam_policies( - scope="scope_value", query="query_value", + scope="scope_value", + query="query_value", ) # Establish that the underlying call was made with the expected @@ -2785,7 +3186,9 @@ def test_search_all_iam_policies_flattened(): def test_search_all_iam_policies_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2799,7 +3202,9 @@ def test_search_all_iam_policies_flattened_error(): @pytest.mark.asyncio async def test_search_all_iam_policies_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2814,7 +3219,8 @@ async def test_search_all_iam_policies_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_all_iam_policies( - scope="scope_value", query="query_value", + scope="scope_value", + query="query_value", ) # Establish that the underlying call was made with the expected @@ -2831,7 +3237,9 @@ async def test_search_all_iam_policies_flattened_async(): @pytest.mark.asyncio async def test_search_all_iam_policies_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2845,7 +3253,8 @@ async def test_search_all_iam_policies_flattened_error_async(): def test_search_all_iam_policies_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2863,10 +3272,14 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -2892,7 +3305,8 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): def test_search_all_iam_policies_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2910,10 +3324,14 @@ def test_search_all_iam_policies_pages(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -2930,7 +3348,9 @@ def test_search_all_iam_policies_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_search_all_iam_policies_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2949,10 +3369,14 @@ async def test_search_all_iam_policies_async_pager(): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -2962,7 +3386,9 @@ async def test_search_all_iam_policies_async_pager(): ), RuntimeError, ) - async_pager = await client.search_all_iam_policies(request={},) + async_pager = await client.search_all_iam_policies( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2974,7 +3400,9 @@ async def test_search_all_iam_policies_async_pager(): @pytest.mark.asyncio async def test_search_all_iam_policies_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2993,10 +3421,14 @@ async def test_search_all_iam_policies_async_pages(): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -3013,10 +3445,17 @@ async def test_search_all_iam_policies_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [asset_service.AnalyzeIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.AnalyzeIamPolicyRequest, + dict, + ], +) def test_analyze_iam_policy(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3028,7 +3467,9 @@ def test_analyze_iam_policy(request_type, transport: str = "grpc"): type(client.transport.analyze_iam_policy), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = asset_service.AnalyzeIamPolicyResponse(fully_explored=True,) + call.return_value = asset_service.AnalyzeIamPolicyResponse( + fully_explored=True, + ) response = client.analyze_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -3045,7 +3486,8 @@ def test_analyze_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3063,7 +3505,8 @@ async def test_analyze_iam_policy_async( transport: str = "grpc_asyncio", request_type=asset_service.AnalyzeIamPolicyRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3076,7 +3519,9 @@ async def test_analyze_iam_policy_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - asset_service.AnalyzeIamPolicyResponse(fully_explored=True,) + asset_service.AnalyzeIamPolicyResponse( + fully_explored=True, + ) ) response = await client.analyze_iam_policy(request) @@ -3096,7 +3541,9 @@ async def test_analyze_iam_policy_async_from_dict(): def test_analyze_iam_policy_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -3126,7 +3573,9 @@ def test_analyze_iam_policy_field_headers(): @pytest.mark.asyncio async def test_analyze_iam_policy_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -3157,11 +3606,16 @@ async def test_analyze_iam_policy_field_headers_async(): @pytest.mark.parametrize( - "request_type", [asset_service.AnalyzeIamPolicyLongrunningRequest, dict,] + "request_type", + [ + asset_service.AnalyzeIamPolicyLongrunningRequest, + dict, + ], ) def test_analyze_iam_policy_longrunning(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3189,7 +3643,8 @@ def test_analyze_iam_policy_longrunning_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3208,7 +3663,8 @@ async def test_analyze_iam_policy_longrunning_async( request_type=asset_service.AnalyzeIamPolicyLongrunningRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3240,7 +3696,9 @@ async def test_analyze_iam_policy_longrunning_async_from_dict(): def test_analyze_iam_policy_longrunning_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -3270,7 +3728,9 @@ def test_analyze_iam_policy_longrunning_field_headers(): @pytest.mark.asyncio async def test_analyze_iam_policy_longrunning_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -3300,10 +3760,17 @@ async def test_analyze_iam_policy_longrunning_field_headers_async(): ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [asset_service.AnalyzeMoveRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.AnalyzeMoveRequest, + dict, + ], +) def test_analyze_move(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3329,7 +3796,8 @@ def test_analyze_move_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3345,7 +3813,8 @@ async def test_analyze_move_async( transport: str = "grpc_asyncio", request_type=asset_service.AnalyzeMoveRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3375,7 +3844,9 @@ async def test_analyze_move_async_from_dict(): def test_analyze_move_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -3395,12 +3866,17 @@ def test_analyze_move_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_analyze_move_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -3422,7 +3898,10 @@ async def test_analyze_move_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -3432,7 +3911,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3452,7 +3932,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = AssetServiceClient(client_options=options, transport=transport,) + client = AssetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3468,7 +3951,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3513,8 +3997,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.AssetServiceGrpcTransport,) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AssetServiceGrpcTransport, + ) def test_asset_service_base_transport_error(): @@ -3576,7 +4065,8 @@ def test_asset_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3731,7 +4221,8 @@ def test_asset_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3743,7 +4234,8 @@ def test_asset_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3844,12 +4336,16 @@ def test_asset_service_transport_channel_mtls_with_adc(transport_class): def test_asset_service_grpc_lro_client(): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3857,12 +4353,16 @@ def test_asset_service_grpc_lro_client(): def test_asset_service_grpc_lro_async_client(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3872,7 +4372,8 @@ def test_access_level_path(): access_policy = "squid" access_level = "clam" expected = "accessPolicies/{access_policy}/accessLevels/{access_level}".format( - access_policy=access_policy, access_level=access_level, + access_policy=access_policy, + access_level=access_level, ) actual = AssetServiceClient.access_level_path(access_policy, access_level) assert expected == actual @@ -3892,7 +4393,9 @@ def test_parse_access_level_path(): def test_access_policy_path(): access_policy = "oyster" - expected = "accessPolicies/{access_policy}".format(access_policy=access_policy,) + expected = "accessPolicies/{access_policy}".format( + access_policy=access_policy, + ) actual = AssetServiceClient.access_policy_path(access_policy) assert expected == actual @@ -3917,7 +4420,10 @@ def test_asset_path(): def test_feed_path(): project = "cuttlefish" feed = "mussel" - expected = "projects/{project}/feeds/{feed}".format(project=project, feed=feed,) + expected = "projects/{project}/feeds/{feed}".format( + project=project, + feed=feed, + ) actual = AssetServiceClient.feed_path(project, feed) assert expected == actual @@ -3938,8 +4444,12 @@ def test_inventory_path(): project = "scallop" location = "abalone" instance = "squid" - expected = "projects/{project}/locations/{location}/instances/{instance}/inventory".format( - project=project, location=location, instance=instance, + expected = ( + "projects/{project}/locations/{location}/instances/{instance}/inventory".format( + project=project, + location=location, + instance=instance, + ) ) actual = AssetServiceClient.inventory_path(project, location, instance) assert expected == actual @@ -3961,8 +4471,11 @@ def test_parse_inventory_path(): def test_service_perimeter_path(): access_policy = "oyster" service_perimeter = "nudibranch" - expected = "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( - access_policy=access_policy, service_perimeter=service_perimeter, + expected = ( + "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, + service_perimeter=service_perimeter, + ) ) actual = AssetServiceClient.service_perimeter_path(access_policy, service_perimeter) assert expected == actual @@ -4002,7 +4515,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -4020,7 +4535,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -4038,7 +4555,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -4058,7 +4577,8 @@ def test_common_location_path(): project = "oyster" location = "nudibranch" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssetServiceClient.common_location_path(project, location) assert expected == actual @@ -4083,7 +4603,8 @@ def test_client_with_default_client_info(): transports.AssetServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4092,7 +4613,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4100,7 +4622,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py index c7e5c348..eaf7718f 100644 --- a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py @@ -82,7 +82,13 @@ def test__get_default_mtls_endpoint(): assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -122,7 +128,13 @@ def test_asset_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -477,7 +489,9 @@ def test_asset_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -616,11 +630,16 @@ def test_asset_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [asset_service.SearchAllResourcesRequest, dict,] + "request_type", + [ + asset_service.SearchAllResourcesRequest, + dict, + ], ) def test_search_all_resources(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -651,7 +670,8 @@ def test_search_all_resources_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -670,7 +690,8 @@ async def test_search_all_resources_async( request_type=asset_service.SearchAllResourcesRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -705,7 +726,9 @@ async def test_search_all_resources_async_from_dict(): def test_search_all_resources_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -727,12 +750,17 @@ def test_search_all_resources_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_search_all_resources_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -756,11 +784,16 @@ async def test_search_all_resources_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] def test_search_all_resources_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -771,7 +804,9 @@ def test_search_all_resources_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_all_resources( - scope="scope_value", query="query_value", asset_types=["asset_types_value"], + scope="scope_value", + query="query_value", + asset_types=["asset_types_value"], ) # Establish that the underlying call was made with the expected @@ -790,7 +825,9 @@ def test_search_all_resources_flattened(): def test_search_all_resources_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -805,7 +842,9 @@ def test_search_all_resources_flattened_error(): @pytest.mark.asyncio async def test_search_all_resources_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -820,7 +859,9 @@ async def test_search_all_resources_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_all_resources( - scope="scope_value", query="query_value", asset_types=["asset_types_value"], + scope="scope_value", + query="query_value", + asset_types=["asset_types_value"], ) # Establish that the underlying call was made with the expected @@ -840,7 +881,9 @@ async def test_search_all_resources_flattened_async(): @pytest.mark.asyncio async def test_search_all_resources_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -855,7 +898,8 @@ async def test_search_all_resources_flattened_error_async(): def test_search_all_resources_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -873,10 +917,14 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.StandardResourceMetadata(),], next_page_token="ghi", + results=[ + assets.StandardResourceMetadata(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( results=[ @@ -902,7 +950,8 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): def test_search_all_resources_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -920,10 +969,14 @@ def test_search_all_resources_pages(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.StandardResourceMetadata(),], next_page_token="ghi", + results=[ + assets.StandardResourceMetadata(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( results=[ @@ -940,7 +993,9 @@ def test_search_all_resources_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_search_all_resources_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -959,10 +1014,14 @@ async def test_search_all_resources_async_pager(): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.StandardResourceMetadata(),], next_page_token="ghi", + results=[ + assets.StandardResourceMetadata(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( results=[ @@ -972,7 +1031,9 @@ async def test_search_all_resources_async_pager(): ), RuntimeError, ) - async_pager = await client.search_all_resources(request={},) + async_pager = await client.search_all_resources( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -984,7 +1045,9 @@ async def test_search_all_resources_async_pager(): @pytest.mark.asyncio async def test_search_all_resources_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1003,10 +1066,14 @@ async def test_search_all_resources_async_pages(): next_page_token="abc", ), asset_service.SearchAllResourcesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllResourcesResponse( - results=[assets.StandardResourceMetadata(),], next_page_token="ghi", + results=[ + assets.StandardResourceMetadata(), + ], + next_page_token="ghi", ), asset_service.SearchAllResourcesResponse( results=[ @@ -1024,11 +1091,16 @@ async def test_search_all_resources_async_pages(): @pytest.mark.parametrize( - "request_type", [asset_service.SearchAllIamPoliciesRequest, dict,] + "request_type", + [ + asset_service.SearchAllIamPoliciesRequest, + dict, + ], ) def test_search_all_iam_policies(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1059,7 +1131,8 @@ def test_search_all_iam_policies_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1078,7 +1151,8 @@ async def test_search_all_iam_policies_async( request_type=asset_service.SearchAllIamPoliciesRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1113,7 +1187,9 @@ async def test_search_all_iam_policies_async_from_dict(): def test_search_all_iam_policies_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1135,12 +1211,17 @@ def test_search_all_iam_policies_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_search_all_iam_policies_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1164,11 +1245,16 @@ async def test_search_all_iam_policies_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "scope=scope/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "scope=scope/value", + ) in kw["metadata"] def test_search_all_iam_policies_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1179,7 +1265,8 @@ def test_search_all_iam_policies_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_all_iam_policies( - scope="scope_value", query="query_value", + scope="scope_value", + query="query_value", ) # Establish that the underlying call was made with the expected @@ -1195,7 +1282,9 @@ def test_search_all_iam_policies_flattened(): def test_search_all_iam_policies_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1209,7 +1298,9 @@ def test_search_all_iam_policies_flattened_error(): @pytest.mark.asyncio async def test_search_all_iam_policies_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1224,7 +1315,8 @@ async def test_search_all_iam_policies_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_all_iam_policies( - scope="scope_value", query="query_value", + scope="scope_value", + query="query_value", ) # Establish that the underlying call was made with the expected @@ -1241,7 +1333,9 @@ async def test_search_all_iam_policies_flattened_async(): @pytest.mark.asyncio async def test_search_all_iam_policies_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1255,7 +1349,8 @@ async def test_search_all_iam_policies_flattened_error_async(): def test_search_all_iam_policies_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1273,10 +1368,14 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -1302,7 +1401,8 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): def test_search_all_iam_policies_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,10 +1420,14 @@ def test_search_all_iam_policies_pages(transport_name: str = "grpc"): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -1340,7 +1444,9 @@ def test_search_all_iam_policies_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_search_all_iam_policies_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1359,10 +1465,14 @@ async def test_search_all_iam_policies_async_pager(): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -1372,7 +1482,9 @@ async def test_search_all_iam_policies_async_pager(): ), RuntimeError, ) - async_pager = await client.search_all_iam_policies(request={},) + async_pager = await client.search_all_iam_policies( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1384,7 +1496,9 @@ async def test_search_all_iam_policies_async_pager(): @pytest.mark.asyncio async def test_search_all_iam_policies_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1403,10 +1517,14 @@ async def test_search_all_iam_policies_async_pages(): next_page_token="abc", ), asset_service.SearchAllIamPoliciesResponse( - results=[], next_page_token="def", + results=[], + next_page_token="def", ), asset_service.SearchAllIamPoliciesResponse( - results=[assets.IamPolicySearchResult(),], next_page_token="ghi", + results=[ + assets.IamPolicySearchResult(), + ], + next_page_token="ghi", ), asset_service.SearchAllIamPoliciesResponse( results=[ @@ -1430,7 +1548,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1450,7 +1569,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = AssetServiceClient(client_options=options, transport=transport,) + client = AssetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1466,7 +1588,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1511,8 +1634,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.AssetServiceGrpcTransport,) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AssetServiceGrpcTransport, + ) def test_asset_service_base_transport_error(): @@ -1558,7 +1686,8 @@ def test_asset_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1713,7 +1842,8 @@ def test_asset_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1725,7 +1855,8 @@ def test_asset_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1846,7 +1977,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -1864,7 +1997,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -1882,7 +2017,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -1902,7 +2039,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssetServiceClient.common_location_path(project, location) assert expected == actual @@ -1927,7 +2065,8 @@ def test_client_with_default_client_info(): transports.AssetServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1936,7 +2075,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1944,7 +2084,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py index 9d92e6a5..75705995 100644 --- a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py @@ -81,7 +81,13 @@ def test__get_default_mtls_endpoint(): assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -121,7 +127,13 @@ def test_asset_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -476,7 +488,9 @@ def test_asset_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -614,10 +628,17 @@ def test_asset_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [asset_service.CreateFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.CreateFeedRequest, + dict, + ], +) def test_create_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -652,7 +673,8 @@ def test_create_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -668,7 +690,8 @@ async def test_create_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.CreateFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -707,7 +730,9 @@ async def test_create_feed_async_from_dict(): def test_create_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -727,12 +752,17 @@ def test_create_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -752,11 +782,16 @@ async def test_create_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feed), "__call__") as call: @@ -764,7 +799,9 @@ def test_create_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_feed(parent="parent_value",) + client.create_feed( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -776,19 +813,24 @@ def test_create_feed_flattened(): def test_create_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.create_feed( - asset_service.CreateFeedRequest(), parent="parent_value", + asset_service.CreateFeedRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_create_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feed), "__call__") as call: @@ -798,7 +840,9 @@ async def test_create_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_feed(parent="parent_value",) + response = await client.create_feed( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -811,20 +855,30 @@ async def test_create_feed_flattened_async(): @pytest.mark.asyncio async def test_create_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_feed( - asset_service.CreateFeedRequest(), parent="parent_value", + asset_service.CreateFeedRequest(), + parent="parent_value", ) -@pytest.mark.parametrize("request_type", [asset_service.GetFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.GetFeedRequest, + dict, + ], +) def test_get_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -859,7 +913,8 @@ def test_get_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -875,7 +930,8 @@ async def test_get_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.GetFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -914,7 +970,9 @@ async def test_get_feed_async_from_dict(): def test_get_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -934,12 +992,17 @@ def test_get_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -959,11 +1022,16 @@ async def test_get_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feed), "__call__") as call: @@ -971,7 +1039,9 @@ def test_get_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_feed(name="name_value",) + client.get_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -983,19 +1053,24 @@ def test_get_feed_flattened(): def test_get_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_feed( - asset_service.GetFeedRequest(), name="name_value", + asset_service.GetFeedRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feed), "__call__") as call: @@ -1005,7 +1080,9 @@ async def test_get_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_feed(name="name_value",) + response = await client.get_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1018,20 +1095,30 @@ async def test_get_feed_flattened_async(): @pytest.mark.asyncio async def test_get_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_feed( - asset_service.GetFeedRequest(), name="name_value", + asset_service.GetFeedRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [asset_service.ListFeedsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ListFeedsRequest, + dict, + ], +) def test_list_feeds(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1057,7 +1144,8 @@ def test_list_feeds_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1073,7 +1161,8 @@ async def test_list_feeds_async( transport: str = "grpc_asyncio", request_type=asset_service.ListFeedsRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1103,7 +1192,9 @@ async def test_list_feeds_async_from_dict(): def test_list_feeds_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1123,12 +1214,17 @@ def test_list_feeds_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_feeds_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1150,11 +1246,16 @@ async def test_list_feeds_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_feeds_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_feeds), "__call__") as call: @@ -1162,7 +1263,9 @@ def test_list_feeds_flattened(): call.return_value = asset_service.ListFeedsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_feeds(parent="parent_value",) + client.list_feeds( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1174,19 +1277,24 @@ def test_list_feeds_flattened(): def test_list_feeds_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_feeds( - asset_service.ListFeedsRequest(), parent="parent_value", + asset_service.ListFeedsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_feeds_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_feeds), "__call__") as call: @@ -1198,7 +1306,9 @@ async def test_list_feeds_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_feeds(parent="parent_value",) + response = await client.list_feeds( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1211,20 +1321,30 @@ async def test_list_feeds_flattened_async(): @pytest.mark.asyncio async def test_list_feeds_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_feeds( - asset_service.ListFeedsRequest(), parent="parent_value", + asset_service.ListFeedsRequest(), + parent="parent_value", ) -@pytest.mark.parametrize("request_type", [asset_service.UpdateFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.UpdateFeedRequest, + dict, + ], +) def test_update_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1259,7 +1379,8 @@ def test_update_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1275,7 +1396,8 @@ async def test_update_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.UpdateFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1314,7 +1436,9 @@ async def test_update_feed_async_from_dict(): def test_update_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1334,12 +1458,17 @@ def test_update_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "feed.name=feed.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "feed.name=feed.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1359,11 +1488,16 @@ async def test_update_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "feed.name=feed.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "feed.name=feed.name/value", + ) in kw["metadata"] def test_update_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -1371,7 +1505,9 @@ def test_update_feed_flattened(): call.return_value = asset_service.Feed() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_feed(feed=asset_service.Feed(name="name_value"),) + client.update_feed( + feed=asset_service.Feed(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1383,7 +1519,9 @@ def test_update_feed_flattened(): def test_update_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1396,7 +1534,9 @@ def test_update_feed_flattened_error(): @pytest.mark.asyncio async def test_update_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -1406,7 +1546,9 @@ async def test_update_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(asset_service.Feed()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_feed(feed=asset_service.Feed(name="name_value"),) + response = await client.update_feed( + feed=asset_service.Feed(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1419,7 +1561,9 @@ async def test_update_feed_flattened_async(): @pytest.mark.asyncio async def test_update_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1430,10 +1574,17 @@ async def test_update_feed_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [asset_service.DeleteFeedRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.DeleteFeedRequest, + dict, + ], +) def test_delete_feed(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1459,7 +1610,8 @@ def test_delete_feed_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1475,7 +1627,8 @@ async def test_delete_feed_async( transport: str = "grpc_asyncio", request_type=asset_service.DeleteFeedRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1503,7 +1656,9 @@ async def test_delete_feed_async_from_dict(): def test_delete_feed_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -1523,12 +1678,17 @@ def test_delete_feed_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_feed_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -1548,11 +1708,16 @@ async def test_delete_feed_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_feed_flattened(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feed), "__call__") as call: @@ -1560,7 +1725,9 @@ def test_delete_feed_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_feed(name="name_value",) + client.delete_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1572,19 +1739,24 @@ def test_delete_feed_flattened(): def test_delete_feed_flattened_error(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_feed( - asset_service.DeleteFeedRequest(), name="name_value", + asset_service.DeleteFeedRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_feed_flattened_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feed), "__call__") as call: @@ -1594,7 +1766,9 @@ async def test_delete_feed_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_feed(name="name_value",) + response = await client.delete_feed( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1607,13 +1781,16 @@ async def test_delete_feed_flattened_async(): @pytest.mark.asyncio async def test_delete_feed_flattened_error_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_feed( - asset_service.DeleteFeedRequest(), name="name_value", + asset_service.DeleteFeedRequest(), + name="name_value", ) @@ -1624,7 +1801,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1644,7 +1822,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = AssetServiceClient(client_options=options, transport=transport,) + client = AssetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1660,7 +1841,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1705,8 +1887,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.AssetServiceGrpcTransport,) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AssetServiceGrpcTransport, + ) def test_asset_service_base_transport_error(): @@ -1755,7 +1942,8 @@ def test_asset_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1910,7 +2098,8 @@ def test_asset_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1922,7 +2111,8 @@ def test_asset_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2024,7 +2214,10 @@ def test_asset_service_transport_channel_mtls_with_adc(transport_class): def test_feed_path(): project = "squid" feed = "clam" - expected = "projects/{project}/feeds/{feed}".format(project=project, feed=feed,) + expected = "projects/{project}/feeds/{feed}".format( + project=project, + feed=feed, + ) actual = AssetServiceClient.feed_path(project, feed) assert expected == actual @@ -2063,7 +2256,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -2081,7 +2276,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -2099,7 +2296,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -2119,7 +2318,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssetServiceClient.common_location_path(project, location) assert expected == actual @@ -2144,7 +2344,8 @@ def test_client_with_default_client_info(): transports.AssetServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2153,7 +2354,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2161,7 +2363,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py index 9ba521be..26da5c9f 100644 --- a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py @@ -87,7 +87,13 @@ def test__get_default_mtls_endpoint(): assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -127,7 +133,13 @@ def test_asset_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -482,7 +494,9 @@ def test_asset_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -620,10 +634,17 @@ def test_asset_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [asset_service.AnalyzeIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.AnalyzeIamPolicyRequest, + dict, + ], +) def test_analyze_iam_policy(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -635,7 +656,9 @@ def test_analyze_iam_policy(request_type, transport: str = "grpc"): type(client.transport.analyze_iam_policy), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = asset_service.AnalyzeIamPolicyResponse(fully_explored=True,) + call.return_value = asset_service.AnalyzeIamPolicyResponse( + fully_explored=True, + ) response = client.analyze_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -652,7 +675,8 @@ def test_analyze_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -670,7 +694,8 @@ async def test_analyze_iam_policy_async( transport: str = "grpc_asyncio", request_type=asset_service.AnalyzeIamPolicyRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -683,7 +708,9 @@ async def test_analyze_iam_policy_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - asset_service.AnalyzeIamPolicyResponse(fully_explored=True,) + asset_service.AnalyzeIamPolicyResponse( + fully_explored=True, + ) ) response = await client.analyze_iam_policy(request) @@ -703,7 +730,9 @@ async def test_analyze_iam_policy_async_from_dict(): def test_analyze_iam_policy_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -733,7 +762,9 @@ def test_analyze_iam_policy_field_headers(): @pytest.mark.asyncio async def test_analyze_iam_policy_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -764,11 +795,16 @@ async def test_analyze_iam_policy_field_headers_async(): @pytest.mark.parametrize( - "request_type", [asset_service.ExportIamPolicyAnalysisRequest, dict,] + "request_type", + [ + asset_service.ExportIamPolicyAnalysisRequest, + dict, + ], ) def test_export_iam_policy_analysis(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -796,7 +832,8 @@ def test_export_iam_policy_analysis_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -815,7 +852,8 @@ async def test_export_iam_policy_analysis_async( request_type=asset_service.ExportIamPolicyAnalysisRequest, ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -847,7 +885,9 @@ async def test_export_iam_policy_analysis_async_from_dict(): def test_export_iam_policy_analysis_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -877,7 +917,9 @@ def test_export_iam_policy_analysis_field_headers(): @pytest.mark.asyncio async def test_export_iam_policy_analysis_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -914,7 +956,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -934,7 +977,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = AssetServiceClient(client_options=options, transport=transport,) + client = AssetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -950,7 +996,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -995,8 +1042,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.AssetServiceGrpcTransport,) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AssetServiceGrpcTransport, + ) def test_asset_service_base_transport_error(): @@ -1047,7 +1099,8 @@ def test_asset_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1202,7 +1255,8 @@ def test_asset_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1214,7 +1268,8 @@ def test_asset_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1315,12 +1370,16 @@ def test_asset_service_transport_channel_mtls_with_adc(transport_class): def test_asset_service_grpc_lro_client(): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1328,12 +1387,16 @@ def test_asset_service_grpc_lro_client(): def test_asset_service_grpc_lro_async_client(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1361,7 +1424,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -1379,7 +1444,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -1397,7 +1464,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -1417,7 +1486,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssetServiceClient.common_location_path(project, location) assert expected == actual @@ -1442,7 +1512,8 @@ def test_client_with_default_client_info(): transports.AssetServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1451,7 +1522,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1459,7 +1531,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index ef94c5ce..a5913029 100644 --- a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -83,7 +83,13 @@ def test__get_default_mtls_endpoint(): assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -123,7 +129,13 @@ def test_asset_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [AssetServiceClient, AssetServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + AssetServiceClient, + AssetServiceAsyncClient, + ], +) def test_asset_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -478,7 +490,9 @@ def test_asset_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -616,10 +630,17 @@ def test_asset_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [asset_service.ListAssetsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ListAssetsRequest, + dict, + ], +) def test_list_assets(request_type, transport: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -648,7 +669,8 @@ def test_list_assets_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 = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -664,7 +686,8 @@ async def test_list_assets_async( transport: str = "grpc_asyncio", request_type=asset_service.ListAssetsRequest ): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -675,7 +698,9 @@ async def test_list_assets_async( with mock.patch.object(type(client.transport.list_assets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - asset_service.ListAssetsResponse(next_page_token="next_page_token_value",) + asset_service.ListAssetsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_assets(request) @@ -695,7 +720,9 @@ async def test_list_assets_async_from_dict(): def test_list_assets_field_headers(): - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceClient( + 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. @@ -715,12 +742,17 @@ def test_list_assets_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_assets_field_headers_async(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = AssetServiceAsyncClient( + 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. @@ -742,12 +774,16 @@ async def test_list_assets_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_assets_pager(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -755,14 +791,29 @@ def test_list_assets_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) @@ -781,7 +832,8 @@ def test_list_assets_pager(transport_name: str = "grpc"): def test_list_assets_pages(transport_name: str = "grpc"): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -789,14 +841,29 @@ def test_list_assets_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) pages = list(client.list_assets(request={}).pages) @@ -806,7 +873,9 @@ def test_list_assets_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_assets_async_pager(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -815,17 +884,34 @@ async def test_list_assets_async_pager(): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) - async_pager = await client.list_assets(request={},) + async_pager = await client.list_assets( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -837,7 +923,9 @@ async def test_list_assets_async_pager(): @pytest.mark.asyncio async def test_list_assets_async_pages(): - client = AssetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -846,14 +934,29 @@ async def test_list_assets_async_pages(): # Set the response to a series of pages. call.side_effect = ( asset_service.ListAssetsResponse( - assets=[assets.Asset(), assets.Asset(), assets.Asset(),], + assets=[ + assets.Asset(), + assets.Asset(), + assets.Asset(), + ], next_page_token="abc", ), - asset_service.ListAssetsResponse(assets=[], next_page_token="def",), asset_service.ListAssetsResponse( - assets=[assets.Asset(),], next_page_token="ghi", + assets=[], + next_page_token="def", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + ], + next_page_token="ghi", + ), + asset_service.ListAssetsResponse( + assets=[ + assets.Asset(), + assets.Asset(), + ], ), - asset_service.ListAssetsResponse(assets=[assets.Asset(), assets.Asset(),],), RuntimeError, ) pages = [] @@ -870,7 +973,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -890,7 +994,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = AssetServiceClient(client_options=options, transport=transport,) + client = AssetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -906,7 +1013,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -951,8 +1059,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = AssetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.AssetServiceGrpcTransport,) + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AssetServiceGrpcTransport, + ) def test_asset_service_base_transport_error(): @@ -995,7 +1108,8 @@ def test_asset_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1150,7 +1264,8 @@ def test_asset_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1162,7 +1277,8 @@ def test_asset_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1265,7 +1381,8 @@ def test_access_level_path(): access_policy = "squid" access_level = "clam" expected = "accessPolicies/{access_policy}/accessLevels/{access_level}".format( - access_policy=access_policy, access_level=access_level, + access_policy=access_policy, + access_level=access_level, ) actual = AssetServiceClient.access_level_path(access_policy, access_level) assert expected == actual @@ -1285,7 +1402,9 @@ def test_parse_access_level_path(): def test_access_policy_path(): access_policy = "oyster" - expected = "accessPolicies/{access_policy}".format(access_policy=access_policy,) + expected = "accessPolicies/{access_policy}".format( + access_policy=access_policy, + ) actual = AssetServiceClient.access_policy_path(access_policy) assert expected == actual @@ -1310,8 +1429,11 @@ def test_asset_path(): def test_service_perimeter_path(): access_policy = "cuttlefish" service_perimeter = "mussel" - expected = "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( - access_policy=access_policy, service_perimeter=service_perimeter, + expected = ( + "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, + service_perimeter=service_perimeter, + ) ) actual = AssetServiceClient.service_perimeter_path(access_policy, service_perimeter) assert expected == actual @@ -1351,7 +1473,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "squid" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -1369,7 +1493,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "whelk" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -1387,7 +1513,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "oyster" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -1407,7 +1535,8 @@ def test_common_location_path(): project = "cuttlefish" location = "mussel" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssetServiceClient.common_location_path(project, location) assert expected == actual @@ -1432,7 +1561,8 @@ def test_client_with_default_client_info(): transports.AssetServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1441,7 +1571,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1449,7 +1580,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" From b51d644b5f5bb04a3f6e71d6cdc59b5d92ff7cd3 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 16:44:28 +0000 Subject: [PATCH 08/30] chore(python): add E231 to .flake8 ignore list (#397) Source-Link: https://github.com/googleapis/synthtool/commit/7ff4aad2ec5af0380e8bd6da1fa06eaadf24ec81 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 --- .flake8 | 2 +- .github/.OwlBot.lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 29227d4c..2e438749 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 87dd0061..9e0a9356 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe + digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 From 50cb937bed9a849e258a81c4775a8bd6b477d90e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 30 Mar 2022 23:52:29 +0200 Subject: [PATCH 09/30] chore(deps): update dependency google-cloud-bigquery to v2.34.3 (#398) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 83d8f1af..a4445bcb 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -2,4 +2,4 @@ google-cloud-storage==2.2.1 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.11.0 -google-cloud-bigquery==2.34.2 +google-cloud-bigquery==2.34.3 From 8ef5d838e4f44b8bf3edf0c09754ce6d68539ab0 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 31 Mar 2022 01:34:57 +0200 Subject: [PATCH 10/30] chore(deps): update dependency google-cloud-bigquery to v3 (#399) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index a4445bcb..fbb9f509 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -2,4 +2,4 @@ google-cloud-storage==2.2.1 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.11.0 -google-cloud-bigquery==2.34.3 +google-cloud-bigquery==3.0.1 From e5fa61d885c2d17686344a1bc13f640c18acb2d1 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:18:14 +0000 Subject: [PATCH 11/30] chore(python): update .pre-commit-config.yaml to use black==22.3.0 (#400) Source-Link: https://github.com/googleapis/synthtool/commit/7804ade3daae0d66649bee8df6c55484c6580b8d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d --- .github/.OwlBot.lock.yaml | 3 ++- .pre-commit-config.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9e0a9356..22cc254a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 + digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d +# created: 2022-03-30T23:44:26.560599165Z diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 From 2f9b0abfb49f3848136cca95e2fd68d3c091414e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 02:12:35 +0000 Subject: [PATCH 12/30] chore(python): Enable size-label bot (#401) Source-Link: https://github.com/googleapis/synthtool/commit/06e82790dd719a165ad32b8a06f8f6ec3e3cae0f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/auto-label.yaml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 22cc254a..58a0b153 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d -# created: 2022-03-30T23:44:26.560599165Z + digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce +# created: 2022-04-01T01:42:03.609279246Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..09c8d735 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,2 @@ +requestsize: + enabled: true From 1be38171e011d1affaa5043a4eb017e379534fa8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 19:36:15 +0000 Subject: [PATCH 13/30] chore(python): refactor unit / system test dependency install (#402) Source-Link: https://github.com/googleapis/synthtool/commit/993985f0fc4b37152e588f0549bcbdaf34666023 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd --- .github/.OwlBot.lock.yaml | 4 +- noxfile.py | 105 ++++++++++++++++++++++++++++++-------- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 58a0b153..fa576229 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce -# created: 2022-04-01T01:42:03.609279246Z + digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd +# created: 2022-04-01T15:48:07.524222836Z diff --git a/noxfile.py b/noxfile.py index 58935cad..9848a1a1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,40 @@ import os import pathlib import shutil +import warnings import nox - BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -81,23 +105,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -121,6 +163,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -143,13 +214,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: From 7f66150b5ad7d3aed083663b2e50e72c193be674 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Sun, 3 Apr 2022 17:53:01 -0600 Subject: [PATCH 14/30] chore: allow releases from v1, v2 branch (#395) * chore: allow releases from v1, v2 branch * chore: update release-please.yml * chore: undo reverts to noxfile --- .github/release-please.yml | 12 ++++++++++++ owlbot.py | 1 + 2 files changed, 13 insertions(+) diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5..5161ab34 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,14 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v2 + handleGHRelease: true + releaseType: python +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/owlbot.py b/owlbot.py index 86060d8a..7de6efd0 100644 --- a/owlbot.py +++ b/owlbot.py @@ -81,6 +81,7 @@ def parse_asset_path.*?@staticmethod""", cov_level=100, ) s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file +python.configure_previous_major_version_branches() # ---------------------------------------------------------------------------- # Samples templates From 254feda1e1ba130c77a4e550b276f0e48f81adc8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:52:21 +0000 Subject: [PATCH 15/30] chore(python): add license header to auto-label.yaml (#405) Source-Link: https://github.com/googleapis/synthtool/commit/eb78c980b52c7c6746d2edb77d9cf7aaa99a2aab Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index fa576229..bc893c97 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd -# created: 2022-04-01T15:48:07.524222836Z + digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 +# created: 2022-04-06T10:30:21.687684602Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml index 09c8d735..41bff0b5 100644 --- a/.github/auto-label.yaml +++ b/.github/auto-label.yaml @@ -1,2 +1,15 @@ +# 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. requestsize: enabled: true From 18f782a268e519d8ffc51981083df788a8b271cc Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 7 Apr 2022 13:13:39 +0200 Subject: [PATCH 16/30] chore(deps): update dependency google-cloud-pubsub to v2.12.0 (#406) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index fbb9f509..4c5ea6ad 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,5 +1,5 @@ google-cloud-storage==2.2.1 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 -google-cloud-pubsub==2.11.0 +google-cloud-pubsub==2.12.0 google-cloud-bigquery==3.0.1 From 77662a32ed4334ead94efea1c08e81c212f0c81b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 01:54:07 +0200 Subject: [PATCH 17/30] chore(deps): update dependency google-cloud-storage to v2.3.0 (#410) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 4c5ea6ad..14b02476 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-storage==2.2.1 +google-cloud-storage==2.3.0 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.12.0 From dd28cb0dd897d9386c45a4ec4d4ce8090d986052 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 13 Apr 2022 20:26:00 -0400 Subject: [PATCH 18/30] chore: use gapic-generator-python 0.65.1 (#411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.65.1 PiperOrigin-RevId: 441524537 Source-Link: https://github.com/googleapis/googleapis/commit/2a273915b3f70fe86c9d2a75470a0b83e48d0abf Source-Link: https://github.com/googleapis/googleapis-gen/commit/ab6756a48c89b5bcb9fb73443cb8e55d574f4643 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWI2NzU2YTQ4Yzg5YjViY2I5ZmI3MzQ0M2NiOGU1NWQ1NzRmNDY0MyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../services/asset_service/async_client.py | 12 +- .../asset_v1/services/asset_service/client.py | 12 +- .../services/asset_service/transports/base.py | 5 + .../services/asset_service/transports/grpc.py | 4 + google/cloud/asset_v1/types/assets.py | 6 +- .../services/asset_service/async_client.py | 4 +- .../services/asset_service/client.py | 4 +- .../services/asset_service/transports/base.py | 5 + .../services/asset_service/transports/grpc.py | 4 + google/cloud/asset_v1p1beta1/types/assets.py | 4 +- .../services/asset_service/async_client.py | 4 +- .../services/asset_service/client.py | 4 +- .../services/asset_service/transports/base.py | 5 + .../services/asset_service/transports/grpc.py | 4 + .../services/asset_service/async_client.py | 4 +- .../services/asset_service/client.py | 4 +- .../services/asset_service/transports/base.py | 5 + .../services/asset_service/transports/grpc.py | 4 + .../cloud/asset_v1p4beta1/types/__init__.py | 4 +- .../services/asset_service/async_client.py | 3 +- .../services/asset_service/client.py | 3 +- .../services/asset_service/transports/base.py | 5 + .../services/asset_service/transports/grpc.py | 4 + .../snippet_metadata_asset_v1.json | 1032 ++++++++++++++++- .../snippet_metadata_asset_v1p1beta1.json | 194 +++- .../snippet_metadata_asset_v1p2beta1.json | 408 ++++++- .../snippet_metadata_asset_v1p4beta1.json | 154 ++- .../snippet_metadata_asset_v1p5beta1.json | 82 +- .../unit/gapic/asset_v1/test_asset_service.py | 93 +- .../asset_v1p1beta1/test_asset_service.py | 87 +- .../asset_v1p2beta1/test_asset_service.py | 75 +- .../asset_v1p4beta1/test_asset_service.py | 75 +- .../asset_v1p5beta1/test_asset_service.py | 81 +- 33 files changed, 2155 insertions(+), 239 deletions(-) diff --git a/google/cloud/asset_v1/services/asset_service/async_client.py b/google/cloud/asset_v1/services/asset_service/async_client.py index 0c02d6a2..12f69e51 100644 --- a/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1/services/asset_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -236,7 +236,6 @@ async def export_assets( the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. - .. code-block:: python from google.cloud import asset_v1 @@ -332,7 +331,6 @@ async def list_assets( r"""Lists assets with time and resource types and returns paged results in response. - .. code-block:: python from google.cloud import asset_v1 @@ -457,7 +455,6 @@ async def batch_get_assets_history( specified asset does not exist, this API returns an INVALID_ARGUMENT error. - .. code-block:: python from google.cloud import asset_v1 @@ -541,7 +538,6 @@ async def create_feed( project/folder/organization to listen to its asset updates. - .. code-block:: python from google.cloud import asset_v1 @@ -765,7 +761,6 @@ async def list_feeds( r"""Lists all asset feeds in a parent project/folder/organization. - .. code-block:: python from google.cloud import asset_v1 @@ -1078,7 +1073,6 @@ async def search_all_resources( the ``cloudasset.assets.searchAllResources`` permission on the desired scope, otherwise the request will be rejected. - .. code-block:: python from google.cloud import asset_v1 @@ -1288,7 +1282,6 @@ async def search_all_iam_policies( ``cloudasset.assets.searchAllIamPolicies`` permission on the desired scope, otherwise the request will be rejected. - .. code-block:: python from google.cloud import asset_v1 @@ -1474,7 +1467,6 @@ async def analyze_iam_policy( r"""Analyzes IAM policies to answer which identities have what accesses on which resources. - .. code-block:: python from google.cloud import asset_v1 @@ -1573,7 +1565,6 @@ async def analyze_iam_policy_longrunning( to poll the operation result. The metadata contains the metadata for the long-running operation. - .. code-block:: python from google.cloud import asset_v1 @@ -1678,7 +1669,6 @@ async def analyze_move( subject to change before the actual resource migration takes place. - .. code-block:: python from google.cloud import asset_v1 diff --git a/google/cloud/asset_v1/services/asset_service/client.py b/google/cloud/asset_v1/services/asset_service/client.py index 2d13cd00..88fe43bb 100644 --- a/google/cloud/asset_v1/services/asset_service/client.py +++ b/google/cloud/asset_v1/services/asset_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -527,7 +527,6 @@ def export_assets( the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. - .. code-block:: python from google.cloud import asset_v1 @@ -624,7 +623,6 @@ def list_assets( r"""Lists assets with time and resource types and returns paged results in response. - .. code-block:: python from google.cloud import asset_v1 @@ -739,7 +737,6 @@ def batch_get_assets_history( specified asset does not exist, this API returns an INVALID_ARGUMENT error. - .. code-block:: python from google.cloud import asset_v1 @@ -814,7 +811,6 @@ def create_feed( project/folder/organization to listen to its asset updates. - .. code-block:: python from google.cloud import asset_v1 @@ -1028,7 +1024,6 @@ def list_feeds( r"""Lists all asset feeds in a parent project/folder/organization. - .. code-block:: python from google.cloud import asset_v1 @@ -1321,7 +1316,6 @@ def search_all_resources( the ``cloudasset.assets.searchAllResources`` permission on the desired scope, otherwise the request will be rejected. - .. code-block:: python from google.cloud import asset_v1 @@ -1522,7 +1516,6 @@ def search_all_iam_policies( ``cloudasset.assets.searchAllIamPolicies`` permission on the desired scope, otherwise the request will be rejected. - .. code-block:: python from google.cloud import asset_v1 @@ -1699,7 +1692,6 @@ def analyze_iam_policy( r"""Analyzes IAM policies to answer which identities have what accesses on which resources. - .. code-block:: python from google.cloud import asset_v1 @@ -1790,7 +1782,6 @@ def analyze_iam_policy_longrunning( to poll the operation result. The metadata contains the metadata for the long-running operation. - .. code-block:: python from google.cloud import asset_v1 @@ -1898,7 +1889,6 @@ def analyze_move( subject to change before the actual resource migration takes place. - .. code-block:: python from google.cloud import asset_v1 diff --git a/google/cloud/asset_v1/services/asset_service/transports/base.py b/google/cloud/asset_v1/services/asset_service/transports/base.py index 48c85f11..e8b5a94f 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1/services/asset_service/transports/base.py @@ -83,6 +83,7 @@ def __init__( 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" @@ -418,5 +419,9 @@ def analyze_move( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("AssetServiceTransport",) diff --git a/google/cloud/asset_v1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1/services/asset_service/transports/grpc.py index 00b273a5..129ff098 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1/services/asset_service/transports/grpc.py @@ -647,5 +647,9 @@ def analyze_move( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("AssetServiceGrpcTransport",) diff --git a/google/cloud/asset_v1/types/assets.py b/google/cloud/asset_v1/types/assets.py index 0e464bd4..b39a6ac8 100644 --- a/google/cloud/asset_v1/types/assets.py +++ b/google/cloud/asset_v1/types/assets.py @@ -555,7 +555,7 @@ class ResourceSearchResult(proto.Message): - use a field query. Example: ``location:us-west*`` - use a free text query. Example: ``us-west*`` - labels (Sequence[google.cloud.asset_v1.types.ResourceSearchResult.LabelsEntry]): + labels (Mapping[str, str]): Labels associated with this resource. See `Labelling and grouping GCP resources `__ @@ -698,7 +698,7 @@ class ResourceSearchResult(proto.Message): attributes of the attached resources are exposed in ``additional_attributes`` field, so as to allow users to search on them. - relationships (Sequence[google.cloud.asset_v1.types.ResourceSearchResult.RelationshipsEntry]): + relationships (Mapping[str, google.cloud.asset_v1.types.RelatedResources]): A map of related resources of this resource, keyed by the relationship type. A relationship type is in the format of {SourceType}*{ACTION}*\ {DestType}. Example: @@ -1001,7 +1001,7 @@ class Explanation(proto.Message): r"""Explanation about the IAM policy search result. Attributes: - matched_permissions (Sequence[google.cloud.asset_v1.types.IamPolicySearchResult.Explanation.MatchedPermissionsEntry]): + matched_permissions (Mapping[str, google.cloud.asset_v1.types.IamPolicySearchResult.Explanation.Permissions]): The map from roles to their included permissions that match the permission query (i.e., a query containing ``policy.role.permissions:``). Example: if query diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py index 5afe3526..da3db720 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -216,7 +216,6 @@ async def search_all_resources( cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be rejected. - .. code-block:: python from google.cloud import asset_v1p1beta1 @@ -365,7 +364,6 @@ async def search_all_iam_policies( cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be rejected. - .. code-block:: python from google.cloud import asset_v1p1beta1 diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/client.py b/google/cloud/asset_v1p1beta1/services/asset_service/client.py index fd5b82b7..ea5bc7f5 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -422,7 +422,6 @@ def search_all_resources( cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be rejected. - .. code-block:: python from google.cloud import asset_v1p1beta1 @@ -561,7 +560,6 @@ def search_all_iam_policies( cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be rejected. - .. code-block:: python from google.cloud import asset_v1p1beta1 diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py index 81debf27..d2d9026f 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/transports/base.py @@ -80,6 +80,7 @@ def __init__( 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" @@ -185,5 +186,9 @@ def search_all_iam_policies( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("AssetServiceTransport",) diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py index abdb3dde..a41ee367 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py @@ -301,5 +301,9 @@ def search_all_iam_policies( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("AssetServiceGrpcTransport",) diff --git a/google/cloud/asset_v1p1beta1/types/assets.py b/google/cloud/asset_v1p1beta1/types/assets.py index abb2ec24..e34bc832 100644 --- a/google/cloud/asset_v1p1beta1/types/assets.py +++ b/google/cloud/asset_v1p1beta1/types/assets.py @@ -58,7 +58,7 @@ class StandardResourceMetadata(proto.Message): location (str): Location can be "global", regional like "us-east1", or zonal like "us-west1-b". - labels (Sequence[google.cloud.asset_v1p1beta1.types.StandardResourceMetadata.LabelsEntry]): + labels (Mapping[str, str]): Labels associated with this resource. See `Labelling and grouping GCP resources `__ @@ -143,7 +143,7 @@ class Explanation(proto.Message): r"""Explanation about the IAM policy search result. Attributes: - matched_permissions (Sequence[google.cloud.asset_v1p1beta1.types.IamPolicySearchResult.Explanation.MatchedPermissionsEntry]): + matched_permissions (Mapping[str, google.cloud.asset_v1p1beta1.types.Permissions]): The map from roles to their included permission matching the permission query (e.g. containing ``policy.role.permissions:``). A sample role string: diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py index a2e5f053..c14b44d7 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -210,7 +210,6 @@ async def create_feed( project/folder/organization to listen to its asset updates. - .. code-block:: python from google.cloud import asset_v1p2beta1 @@ -434,7 +433,6 @@ async def list_feeds( r"""Lists all asset feeds in a parent project/folder/organization. - .. code-block:: python from google.cloud import asset_v1p2beta1 diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/client.py b/google/cloud/asset_v1p2beta1/services/asset_service/client.py index 077e13f8..75fd2ed5 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -431,7 +431,6 @@ def create_feed( project/folder/organization to listen to its asset updates. - .. code-block:: python from google.cloud import asset_v1p2beta1 @@ -645,7 +644,6 @@ def list_feeds( r"""Lists all asset feeds in a parent project/folder/organization. - .. code-block:: python from google.cloud import asset_v1p2beta1 diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py index f2529afc..5980fbfa 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/transports/base.py @@ -81,6 +81,7 @@ def __init__( 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" @@ -234,5 +235,9 @@ def delete_feed( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("AssetServiceTransport",) diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py index 2b6aac8c..be9549b1 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py @@ -362,5 +362,9 @@ def delete_feed( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("AssetServiceGrpcTransport",) diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py index 039c5893..ad50c3a7 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -211,7 +211,6 @@ async def analyze_iam_policy( [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the request. - .. code-block:: python from google.cloud import asset_v1p4beta1 @@ -303,7 +302,6 @@ async def export_iam_policy_analysis( allowing you to keep track of the export. The metadata contains the request to help callers to map responses to requests. - .. code-block:: python from google.cloud import asset_v1p4beta1 diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/client.py b/google/cloud/asset_v1p4beta1/services/asset_service/client.py index 4a4f7013..3d8a7ac9 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -417,7 +417,6 @@ def analyze_iam_policy( [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the request. - .. code-block:: python from google.cloud import asset_v1p4beta1 @@ -501,7 +500,6 @@ def export_iam_policy_analysis( allowing you to keep track of the export. The metadata contains the request to help callers to map responses to requests. - .. code-block:: python from google.cloud import asset_v1p4beta1 diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py index 3bd030c6..5242c401 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/transports/base.py @@ -82,6 +82,7 @@ def __init__( 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" @@ -178,5 +179,9 @@ def export_iam_policy_analysis( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("AssetServiceTransport",) diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py index ab75d3c7..1381f78c 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/transports/grpc.py @@ -310,5 +310,9 @@ def export_iam_policy_analysis( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("AssetServiceGrpcTransport",) diff --git a/google/cloud/asset_v1p4beta1/types/__init__.py b/google/cloud/asset_v1p4beta1/types/__init__.py index 7e854ed0..f83fdd2d 100644 --- a/google/cloud/asset_v1p4beta1/types/__init__.py +++ b/google/cloud/asset_v1p4beta1/types/__init__.py @@ -21,7 +21,9 @@ IamPolicyAnalysisOutputConfig, IamPolicyAnalysisQuery, ) -from .assets import IamPolicyAnalysisResult +from .assets import ( + IamPolicyAnalysisResult, +) __all__ = ( "AnalyzeIamPolicyRequest", diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index 0c8879e4..1d24e0a7 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -218,7 +218,6 @@ async def list_assets( r"""Lists assets with time and resource types and returns paged results in response. - .. code-block:: python from google.cloud import asset_v1p5beta1 diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/client.py b/google/cloud/asset_v1p5beta1/services/asset_service/client.py index 983acd35..b81f9996 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -474,7 +474,6 @@ def list_assets( r"""Lists assets with time and resource types and returns paged results in response. - .. code-block:: python from google.cloud import asset_v1p5beta1 diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py b/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py index 3123ad4b..f8467379 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/transports/base.py @@ -80,6 +80,7 @@ def __init__( 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" @@ -158,5 +159,9 @@ def list_assets( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("AssetServiceTransport",) diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py index 85eb92a9..5ff4a274 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py @@ -257,5 +257,9 @@ def list_assets( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("AssetServiceGrpcTransport",) diff --git a/samples/generated_samples/snippet_metadata_asset_v1.json b/samples/generated_samples/snippet_metadata_asset_v1.json index 1d3a68fd..75479410 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1.json @@ -1,16 +1,57 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.asset.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-asset" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.analyze_iam_policy_longrunning", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicyLongrunning" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "analyze_iam_policy_longrunning" }, + "description": "Sample for AnalyzeIamPolicyLongrunning", "file": "cloudasset_v1_generated_asset_service_analyze_iam_policy_longrunning_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_async", "segments": [ { @@ -43,18 +84,50 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_iam_policy_longrunning_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.analyze_iam_policy_longrunning", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicyLongrunning" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "analyze_iam_policy_longrunning" }, + "description": "Sample for AnalyzeIamPolicyLongrunning", "file": "cloudasset_v1_generated_asset_service_analyze_iam_policy_longrunning_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_sync", "segments": [ { @@ -87,19 +160,51 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_iam_policy_longrunning_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.analyze_iam_policy", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeIamPolicy", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.AnalyzeIamPolicyResponse", + "shortName": "analyze_iam_policy" }, + "description": "Sample for AnalyzeIamPolicy", "file": "cloudasset_v1_generated_asset_service_analyze_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_async", "segments": [ { @@ -132,18 +237,50 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.analyze_iam_policy", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeIamPolicy", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.AnalyzeIamPolicyResponse", + "shortName": "analyze_iam_policy" }, + "description": "Sample for AnalyzeIamPolicy", "file": "cloudasset_v1_generated_asset_service_analyze_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_sync", "segments": [ { @@ -176,19 +313,51 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.analyze_move", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeMove", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeMove" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeMoveRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.AnalyzeMoveResponse", + "shortName": "analyze_move" }, + "description": "Sample for AnalyzeMove", "file": "cloudasset_v1_generated_asset_service_analyze_move_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeMove_async", "segments": [ { @@ -221,18 +390,50 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_move_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.analyze_move", "method": { + "fullName": "google.cloud.asset.v1.AssetService.AnalyzeMove", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeMove" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.AnalyzeMoveRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.AnalyzeMoveResponse", + "shortName": "analyze_move" }, + "description": "Sample for AnalyzeMove", "file": "cloudasset_v1_generated_asset_service_analyze_move_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_AnalyzeMove_sync", "segments": [ { @@ -265,19 +466,51 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_analyze_move_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.batch_get_assets_history", "method": { + "fullName": "google.cloud.asset.v1.AssetService.BatchGetAssetsHistory", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "BatchGetAssetsHistory" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.BatchGetAssetsHistoryRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse", + "shortName": "batch_get_assets_history" }, + "description": "Sample for BatchGetAssetsHistory", "file": "cloudasset_v1_generated_asset_service_batch_get_assets_history_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_async", "segments": [ { @@ -310,18 +543,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_batch_get_assets_history_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.batch_get_assets_history", "method": { + "fullName": "google.cloud.asset.v1.AssetService.BatchGetAssetsHistory", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "BatchGetAssetsHistory" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.BatchGetAssetsHistoryRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse", + "shortName": "batch_get_assets_history" }, + "description": "Sample for BatchGetAssetsHistory", "file": "cloudasset_v1_generated_asset_service_batch_get_assets_history_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_sync", "segments": [ { @@ -354,19 +619,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_batch_get_assets_history_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.create_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "CreateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "create_feed" }, + "description": "Sample for CreateFeed", "file": "cloudasset_v1_generated_asset_service_create_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_async", "segments": [ { @@ -399,18 +700,54 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_create_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.create_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "CreateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "create_feed" }, + "description": "Sample for CreateFeed", "file": "cloudasset_v1_generated_asset_service_create_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_sync", "segments": [ { @@ -443,19 +780,54 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_create_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.delete_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "DeleteFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + }, + { + "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_feed" }, + "description": "Sample for DeleteFeed", "file": "cloudasset_v1_generated_asset_service_delete_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_async", "segments": [ { @@ -486,18 +858,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_delete_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.delete_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "DeleteFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + }, + { + "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_feed" }, + "description": "Sample for DeleteFeed", "file": "cloudasset_v1_generated_asset_service_delete_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_sync", "segments": [ { @@ -528,19 +935,51 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_delete_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.export_assets", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ExportAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ExportAssetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_assets" }, + "description": "Sample for ExportAssets", "file": "cloudasset_v1_generated_asset_service_export_assets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_async", "segments": [ { @@ -573,18 +1012,50 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_export_assets_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.export_assets", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ExportAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ExportAssetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_assets" }, + "description": "Sample for ExportAssets", "file": "cloudasset_v1_generated_asset_service_export_assets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_sync", "segments": [ { @@ -617,19 +1088,55 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_export_assets_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.get_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.GetFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "GetFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.GetFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "get_feed" }, + "description": "Sample for GetFeed", "file": "cloudasset_v1_generated_asset_service_get_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_async", "segments": [ { @@ -662,18 +1169,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_get_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.get_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.GetFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "GetFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.GetFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "get_feed" }, + "description": "Sample for GetFeed", "file": "cloudasset_v1_generated_asset_service_get_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_sync", "segments": [ { @@ -706,19 +1249,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_get_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_assets", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ListAssets", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ListAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ListAssetsRequest" + }, + { + "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.asset_v1.services.asset_service.pagers.ListAssetsAsyncPager", + "shortName": "list_assets" }, + "description": "Sample for ListAssets", "file": "cloudasset_v1_generated_asset_service_list_assets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_async", "segments": [ { @@ -751,18 +1330,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_list_assets_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.list_assets", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ListAssets", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ListAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ListAssetsRequest" + }, + { + "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.asset_v1.services.asset_service.pagers.ListAssetsPager", + "shortName": "list_assets" }, + "description": "Sample for ListAssets", "file": "cloudasset_v1_generated_asset_service_list_assets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_sync", "segments": [ { @@ -795,19 +1410,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_list_assets_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_feeds", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ListFeeds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ListFeedsRequest" + }, + { + "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.asset_v1.types.ListFeedsResponse", + "shortName": "list_feeds" }, + "description": "Sample for ListFeeds", "file": "cloudasset_v1_generated_asset_service_list_feeds_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_async", "segments": [ { @@ -840,18 +1491,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_list_feeds_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.list_feeds", "method": { + "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "ListFeeds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.ListFeedsRequest" + }, + { + "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.asset_v1.types.ListFeedsResponse", + "shortName": "list_feeds" }, + "description": "Sample for ListFeeds", "file": "cloudasset_v1_generated_asset_service_list_feeds_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_sync", "segments": [ { @@ -884,19 +1571,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_list_feeds_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.search_all_iam_policies", "method": { + "fullName": "google.cloud.asset.v1.AssetService.SearchAllIamPolicies", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllIamPolicies" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.SearchAllIamPoliciesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager", + "shortName": "search_all_iam_policies" }, + "description": "Sample for SearchAllIamPolicies", "file": "cloudasset_v1_generated_asset_service_search_all_iam_policies_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_SearchAllIamPolicies_async", "segments": [ { @@ -929,18 +1656,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_search_all_iam_policies_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.search_all_iam_policies", "method": { + "fullName": "google.cloud.asset.v1.AssetService.SearchAllIamPolicies", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllIamPolicies" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.SearchAllIamPoliciesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesPager", + "shortName": "search_all_iam_policies" }, + "description": "Sample for SearchAllIamPolicies", "file": "cloudasset_v1_generated_asset_service_search_all_iam_policies_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_SearchAllIamPolicies_sync", "segments": [ { @@ -973,19 +1740,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_search_all_iam_policies_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.search_all_resources", "method": { + "fullName": "google.cloud.asset.v1.AssetService.SearchAllResources", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllResources" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.SearchAllResourcesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "asset_types", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllResourcesAsyncPager", + "shortName": "search_all_resources" }, + "description": "Sample for SearchAllResources", "file": "cloudasset_v1_generated_asset_service_search_all_resources_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_SearchAllResources_async", "segments": [ { @@ -1018,18 +1829,62 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_search_all_resources_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.search_all_resources", "method": { + "fullName": "google.cloud.asset.v1.AssetService.SearchAllResources", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllResources" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.SearchAllResourcesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "asset_types", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllResourcesPager", + "shortName": "search_all_resources" }, + "description": "Sample for SearchAllResources", "file": "cloudasset_v1_generated_asset_service_search_all_resources_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_SearchAllResources_sync", "segments": [ { @@ -1062,19 +1917,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_search_all_resources_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.update_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.UpdateFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "UpdateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.UpdateFeedRequest" + }, + { + "name": "feed", + "type": "google.cloud.asset_v1.types.Feed" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.Feed", + "shortName": "update_feed" }, + "description": "Sample for UpdateFeed", "file": "cloudasset_v1_generated_asset_service_update_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_UpdateFeed_async", "segments": [ { @@ -1107,18 +1998,54 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_update_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.update_feed", "method": { + "fullName": "google.cloud.asset.v1.AssetService.UpdateFeed", "service": { + "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, "shortName": "UpdateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.UpdateFeedRequest" + }, + { + "name": "feed", + "type": "google.cloud.asset_v1.types.Feed" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.Feed", + "shortName": "update_feed" }, + "description": "Sample for UpdateFeed", "file": "cloudasset_v1_generated_asset_service_update_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1_generated_AssetService_UpdateFeed_sync", "segments": [ { @@ -1151,7 +2078,8 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1_generated_asset_service_update_feed_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_asset_v1p1beta1.json b/samples/generated_samples/snippet_metadata_asset_v1p1beta1.json index f9a3789f..e621a91d 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1p1beta1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1p1beta1.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.asset.v1p1beta1", + "version": "v1p1beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-asset" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceAsyncClient.search_all_iam_policies", "method": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService.SearchAllIamPolicies", "service": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllIamPolicies" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p1beta1.types.SearchAllIamPoliciesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager", + "shortName": "search_all_iam_policies" }, + "description": "Sample for SearchAllIamPolicies", "file": "cloudasset_v1p1beta1_generated_asset_service_search_all_iam_policies_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p1beta1_generated_AssetService_SearchAllIamPolicies_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p1beta1_generated_asset_service_search_all_iam_policies_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceClient.search_all_iam_policies", "method": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService.SearchAllIamPolicies", "service": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllIamPolicies" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p1beta1.types.SearchAllIamPoliciesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesPager", + "shortName": "search_all_iam_policies" }, + "description": "Sample for SearchAllIamPolicies", "file": "cloudasset_v1p1beta1_generated_asset_service_search_all_iam_policies_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p1beta1_generated_AssetService_SearchAllIamPolicies_sync", "segments": [ { @@ -87,19 +176,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p1beta1_generated_asset_service_search_all_iam_policies_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceAsyncClient.search_all_resources", "method": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService.SearchAllResources", "service": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllResources" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p1beta1.types.SearchAllResourcesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "asset_types", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesAsyncPager", + "shortName": "search_all_resources" }, + "description": "Sample for SearchAllResources", "file": "cloudasset_v1p1beta1_generated_asset_service_search_all_resources_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p1beta1_generated_AssetService_SearchAllResources_async", "segments": [ { @@ -132,18 +265,62 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p1beta1_generated_asset_service_search_all_resources_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p1beta1.AssetServiceClient.search_all_resources", "method": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService.SearchAllResources", "service": { + "fullName": "google.cloud.asset.v1p1beta1.AssetService", "shortName": "AssetService" }, "shortName": "SearchAllResources" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p1beta1.types.SearchAllResourcesRequest" + }, + { + "name": "scope", + "type": "str" + }, + { + "name": "query", + "type": "str" + }, + { + "name": "asset_types", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesPager", + "shortName": "search_all_resources" }, + "description": "Sample for SearchAllResources", "file": "cloudasset_v1p1beta1_generated_asset_service_search_all_resources_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p1beta1_generated_AssetService_SearchAllResources_sync", "segments": [ { @@ -176,7 +353,8 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p1beta1_generated_asset_service_search_all_resources_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_asset_v1p2beta1.json b/samples/generated_samples/snippet_metadata_asset_v1p2beta1.json index 0c20c26d..f03b7f27 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1p2beta1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1p2beta1.json @@ -1,16 +1,61 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.asset.v1p2beta1", + "version": "v1p2beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-asset" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient.create_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.CreateFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "CreateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.CreateFeedRequest" + }, + { + "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.asset_v1p2beta1.types.Feed", + "shortName": "create_feed" }, + "description": "Sample for CreateFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_create_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_CreateFeed_async", "segments": [ { @@ -43,18 +88,54 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_create_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient.create_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.CreateFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "CreateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.CreateFeedRequest" + }, + { + "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.asset_v1p2beta1.types.Feed", + "shortName": "create_feed" }, + "description": "Sample for CreateFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_create_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_CreateFeed_sync", "segments": [ { @@ -87,19 +168,54 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_create_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient.delete_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.DeleteFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "DeleteFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.DeleteFeedRequest" + }, + { + "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_feed" }, + "description": "Sample for DeleteFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_delete_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_DeleteFeed_async", "segments": [ { @@ -130,18 +246,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_delete_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient.delete_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.DeleteFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "DeleteFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.DeleteFeedRequest" + }, + { + "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_feed" }, + "description": "Sample for DeleteFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_delete_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_DeleteFeed_sync", "segments": [ { @@ -172,19 +323,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_delete_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient.get_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.GetFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "GetFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.GetFeedRequest" + }, + { + "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.asset_v1p2beta1.types.Feed", + "shortName": "get_feed" }, + "description": "Sample for GetFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_get_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_GetFeed_async", "segments": [ { @@ -217,18 +404,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_get_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient.get_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.GetFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "GetFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.GetFeedRequest" + }, + { + "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.asset_v1p2beta1.types.Feed", + "shortName": "get_feed" }, + "description": "Sample for GetFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_get_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_GetFeed_sync", "segments": [ { @@ -261,19 +484,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_get_feed_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient.list_feeds", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.ListFeeds", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "ListFeeds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.ListFeedsRequest" + }, + { + "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.asset_v1p2beta1.types.ListFeedsResponse", + "shortName": "list_feeds" }, + "description": "Sample for ListFeeds", "file": "cloudasset_v1p2beta1_generated_asset_service_list_feeds_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_ListFeeds_async", "segments": [ { @@ -306,18 +565,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_list_feeds_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient.list_feeds", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.ListFeeds", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "ListFeeds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.ListFeedsRequest" + }, + { + "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.asset_v1p2beta1.types.ListFeedsResponse", + "shortName": "list_feeds" }, + "description": "Sample for ListFeeds", "file": "cloudasset_v1p2beta1_generated_asset_service_list_feeds_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_ListFeeds_sync", "segments": [ { @@ -350,19 +645,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_list_feeds_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceAsyncClient.update_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.UpdateFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "UpdateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.UpdateFeedRequest" + }, + { + "name": "feed", + "type": "google.cloud.asset_v1p2beta1.types.Feed" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p2beta1.types.Feed", + "shortName": "update_feed" }, + "description": "Sample for UpdateFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_update_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_UpdateFeed_async", "segments": [ { @@ -395,18 +726,54 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_update_feed_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p2beta1.AssetServiceClient.update_feed", "method": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService.UpdateFeed", "service": { + "fullName": "google.cloud.asset.v1p2beta1.AssetService", "shortName": "AssetService" }, "shortName": "UpdateFeed" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p2beta1.types.UpdateFeedRequest" + }, + { + "name": "feed", + "type": "google.cloud.asset_v1p2beta1.types.Feed" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p2beta1.types.Feed", + "shortName": "update_feed" }, + "description": "Sample for UpdateFeed", "file": "cloudasset_v1p2beta1_generated_asset_service_update_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p2beta1_generated_AssetService_UpdateFeed_sync", "segments": [ { @@ -439,7 +806,8 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p2beta1_generated_asset_service_update_feed_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_asset_v1p4beta1.json b/samples/generated_samples/snippet_metadata_asset_v1p4beta1.json index a91113b4..f68b216f 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1p4beta1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1p4beta1.json @@ -1,16 +1,57 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.asset.v1p4beta1", + "version": "v1p4beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-asset" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceAsyncClient.analyze_iam_policy", "method": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService.AnalyzeIamPolicy", "service": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p4beta1.types.AnalyzeIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p4beta1.types.AnalyzeIamPolicyResponse", + "shortName": "analyze_iam_policy" }, + "description": "Sample for AnalyzeIamPolicy", "file": "cloudasset_v1p4beta1_generated_asset_service_analyze_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p4beta1_generated_AssetService_AnalyzeIamPolicy_async", "segments": [ { @@ -43,18 +84,50 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p4beta1_generated_asset_service_analyze_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceClient.analyze_iam_policy", "method": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService.AnalyzeIamPolicy", "service": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService", "shortName": "AssetService" }, "shortName": "AnalyzeIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p4beta1.types.AnalyzeIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p4beta1.types.AnalyzeIamPolicyResponse", + "shortName": "analyze_iam_policy" }, + "description": "Sample for AnalyzeIamPolicy", "file": "cloudasset_v1p4beta1_generated_asset_service_analyze_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p4beta1_generated_AssetService_AnalyzeIamPolicy_sync", "segments": [ { @@ -87,19 +160,51 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p4beta1_generated_asset_service_analyze_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceAsyncClient.export_iam_policy_analysis", "method": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService.ExportIamPolicyAnalysis", "service": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService", "shortName": "AssetService" }, "shortName": "ExportIamPolicyAnalysis" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p4beta1.types.ExportIamPolicyAnalysisRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_iam_policy_analysis" }, + "description": "Sample for ExportIamPolicyAnalysis", "file": "cloudasset_v1p4beta1_generated_asset_service_export_iam_policy_analysis_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p4beta1_generated_AssetService_ExportIamPolicyAnalysis_async", "segments": [ { @@ -132,18 +237,50 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p4beta1_generated_asset_service_export_iam_policy_analysis_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p4beta1.AssetServiceClient.export_iam_policy_analysis", "method": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService.ExportIamPolicyAnalysis", "service": { + "fullName": "google.cloud.asset.v1p4beta1.AssetService", "shortName": "AssetService" }, "shortName": "ExportIamPolicyAnalysis" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p4beta1.types.ExportIamPolicyAnalysisRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_iam_policy_analysis" }, + "description": "Sample for ExportIamPolicyAnalysis", "file": "cloudasset_v1p4beta1_generated_asset_service_export_iam_policy_analysis_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p4beta1_generated_AssetService_ExportIamPolicyAnalysis_sync", "segments": [ { @@ -176,7 +313,8 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p4beta1_generated_asset_service_export_iam_policy_analysis_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_asset_v1p5beta1.json b/samples/generated_samples/snippet_metadata_asset_v1p5beta1.json index 291cde2d..b9a50c2c 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1p5beta1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1p5beta1.json @@ -1,16 +1,57 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.asset.v1p5beta1", + "version": "v1p5beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-asset" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.asset_v1p5beta1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1p5beta1.AssetServiceAsyncClient.list_assets", "method": { + "fullName": "google.cloud.asset.v1p5beta1.AssetService.ListAssets", "service": { + "fullName": "google.cloud.asset.v1p5beta1.AssetService", "shortName": "AssetService" }, "shortName": "ListAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p5beta1.types.ListAssetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p5beta1.services.asset_service.pagers.ListAssetsAsyncPager", + "shortName": "list_assets" }, + "description": "Sample for ListAssets", "file": "cloudasset_v1p5beta1_generated_asset_service_list_assets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p5beta1_generated_AssetService_ListAssets_async", "segments": [ { @@ -43,18 +84,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p5beta1_generated_asset_service_list_assets_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1p5beta1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1p5beta1.AssetServiceClient.list_assets", "method": { + "fullName": "google.cloud.asset.v1p5beta1.AssetService.ListAssets", "service": { + "fullName": "google.cloud.asset.v1p5beta1.AssetService", "shortName": "AssetService" }, "shortName": "ListAssets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1p5beta1.types.ListAssetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1p5beta1.services.asset_service.pagers.ListAssetsPager", + "shortName": "list_assets" }, + "description": "Sample for ListAssets", "file": "cloudasset_v1p5beta1_generated_asset_service_list_assets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudasset_v1p5beta1_generated_AssetService_ListAssets_sync", "segments": [ { @@ -87,7 +160,8 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudasset_v1p5beta1_generated_asset_service_list_assets_sync.py" } ] } diff --git a/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/unit/gapic/asset_v1/test_asset_service.py index a9a6632a..3dabd1d3 100644 --- a/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1/test_asset_service.py @@ -92,24 +92,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_info(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") @pytest.mark.parametrize( @@ -138,27 +138,31 @@ def test_asset_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_file(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") def test_asset_service_client_get_transport_class(): @@ -1148,7 +1152,7 @@ async def test_list_assets_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 @@ -1194,7 +1198,9 @@ async def test_list_assets_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_assets(request={})).pages: + async for page_ in ( + await client.list_assets(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 @@ -2940,7 +2946,7 @@ async def test_search_all_resources_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 @@ -2988,7 +2994,9 @@ async def test_search_all_resources_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.search_all_resources(request={})).pages: + async for page_ in ( + await client.search_all_resources(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 @@ -3391,7 +3399,7 @@ async def test_search_all_iam_policies_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 @@ -3439,7 +3447,9 @@ async def test_search_all_iam_policies_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.search_all_iam_policies(request={})).pages: + async for page_ in ( + await client.search_all_iam_policies(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 @@ -3995,6 +4005,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = AssetServiceClient.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 = AssetServiceClient( @@ -4054,6 +4077,14 @@ def test_asset_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_asset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4196,24 +4227,40 @@ def test_asset_service_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_asset_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_no_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") -def test_asset_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_with_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:8000" + assert client.transport._host == ("cloudasset.googleapis.com:8000") def test_asset_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py index eaf7718f..d8199fbe 100644 --- a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py @@ -83,24 +83,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_info(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") @pytest.mark.parametrize( @@ -129,27 +129,31 @@ def test_asset_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_file(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") def test_asset_service_client_get_transport_class(): @@ -1036,7 +1040,7 @@ async def test_search_all_resources_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 @@ -1084,7 +1088,9 @@ async def test_search_all_resources_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.search_all_resources(request={})).pages: + async for page_ in ( + await client.search_all_resources(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 @@ -1487,7 +1493,7 @@ async def test_search_all_iam_policies_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 @@ -1535,7 +1541,9 @@ async def test_search_all_iam_policies_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.search_all_iam_policies(request={})).pages: + async for page_ in ( + await client.search_all_iam_policies(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 @@ -1632,6 +1640,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = AssetServiceClient.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 = AssetServiceClient( @@ -1675,6 +1696,14 @@ def test_asset_service_base_transport(): 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_asset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1817,24 +1846,40 @@ def test_asset_service_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_asset_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_no_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") -def test_asset_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_with_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:8000" + assert client.transport._host == ("cloudasset.googleapis.com:8000") def test_asset_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py index 75705995..5e0e9bc8 100644 --- a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py @@ -82,24 +82,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_info(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") @pytest.mark.parametrize( @@ -128,27 +128,31 @@ def test_asset_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_file(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") def test_asset_service_client_get_transport_class(): @@ -1885,6 +1889,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = AssetServiceClient.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 = AssetServiceClient( @@ -1931,6 +1948,14 @@ def test_asset_service_base_transport(): 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_asset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2073,24 +2098,40 @@ def test_asset_service_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_asset_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_no_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") -def test_asset_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_with_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:8000" + assert client.transport._host == ("cloudasset.googleapis.com:8000") def test_asset_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py index 26da5c9f..3c8c9efb 100644 --- a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py @@ -88,24 +88,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_info(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") @pytest.mark.parametrize( @@ -134,27 +134,31 @@ def test_asset_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_file(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") def test_asset_service_client_get_transport_class(): @@ -1040,6 +1044,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = AssetServiceClient.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 = AssetServiceClient( @@ -1088,6 +1105,14 @@ def test_asset_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_asset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1230,24 +1255,40 @@ def test_asset_service_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_asset_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_no_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") -def test_asset_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_with_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:8000" + assert client.transport._host == ("cloudasset.googleapis.com:8000") def test_asset_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index a5913029..16d34971 100644 --- a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -84,24 +84,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_info(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") @pytest.mark.parametrize( @@ -130,27 +130,31 @@ def test_asset_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - AssetServiceClient, - AssetServiceAsyncClient, + (AssetServiceClient, "grpc"), + (AssetServiceAsyncClient, "grpc_asyncio"), ], ) -def test_asset_service_client_from_service_account_file(client_class): +def test_asset_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 == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") def test_asset_service_client_get_transport_class(): @@ -914,7 +918,7 @@ async def test_list_assets_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 @@ -960,7 +964,9 @@ async def test_list_assets_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_assets(request={})).pages: + async for page_ in ( + await client.list_assets(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 @@ -1057,6 +1063,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = AssetServiceClient.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 = AssetServiceClient( @@ -1097,6 +1116,14 @@ def test_asset_service_base_transport(): 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_asset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1239,24 +1266,40 @@ def test_asset_service_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_asset_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_no_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:443" + assert client.transport._host == ("cloudasset.googleapis.com:443") -def test_asset_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_asset_service_host_with_port(transport_name): client = AssetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudasset.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudasset.googleapis.com:8000" + assert client.transport._host == ("cloudasset.googleapis.com:8000") def test_asset_service_grpc_transport_channel(): From bdd0821f4ad1a683920036402a95583c5414c94d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:10:57 -0400 Subject: [PATCH 19/30] chore(python): add nox session to sort python imports (#412) Source-Link: https://github.com/googleapis/synthtool/commit/1b71c10e20de7ed3f97f692f99a0e3399b67049f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- noxfile.py | 27 ++++++++++++++++++++++++--- samples/snippets/noxfile.py | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bc893c97..7c454abf 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 -# created: 2022-04-06T10:30:21.687684602Z + digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 +# created: 2022-04-20T23:42:53.970438194Z diff --git a/noxfile.py b/noxfile.py index 9848a1a1..af6ae3f8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,7 +25,8 @@ import nox BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -83,7 +84,7 @@ def lint(session): session.run( "black", "--check", - *BLACK_PATHS, + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -94,7 +95,27 @@ def blacken(session): session.install(BLACK_VERSION) session.run( "black", - *BLACK_PATHS, + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 949e0fde..38bb0a57 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -30,6 +30,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # From bd22f780147d9fb62ce7692402f5354b86bb6741 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:08:15 +0000 Subject: [PATCH 20/30] chore(python): use ubuntu 22.04 in docs image (#414) Source-Link: https://github.com/googleapis/synthtool/commit/f15cc72fb401b4861cedebb10af74afe428fb1f8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/docker/docs/Dockerfile | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7c454abf..64f82d6b 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 -# created: 2022-04-20T23:42:53.970438194Z + digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd +# created: 2022-04-21T15:43:16.246106921Z diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8..238b87b9 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] From 54c46d11ab6f0511d253725c98f6f63228018483 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 25 Apr 2022 17:14:34 +0200 Subject: [PATCH 21/30] chore(deps): update dependency pytest to v7.1.2 (#415) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 8479de71..bf31abc1 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 flaky==3.7.0 -pytest==7.1.1 +pytest==7.1.2 From 7846643d41f5c623247357ed35ed26663452f36f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:05:59 +0200 Subject: [PATCH 22/30] chore(deps): update dependency backoff to v2 (#417) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index bf31abc1..a443e90a 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==1.11.1 +backoff==2.0.0 flaky==3.7.0 pytest==7.1.2 From 5dbb0d72eb145f3cbe23e3900205969ba5ee02a9 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 09:42:59 -0400 Subject: [PATCH 23/30] chore: use gapic-generator-python 0.65.2 (#418) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.65.2 PiperOrigin-RevId: 444333013 Source-Link: https://github.com/googleapis/googleapis/commit/f91b6cf82e929280f6562f6110957c654bd9e2e6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/16eb36095c294e712c74a1bf23550817b42174e5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZlYjM2MDk1YzI5NGU3MTJjNzRhMWJmMjM1NTA4MTdiNDIxNzRlNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../services/asset_service/async_client.py | 78 ++++++------- .../services/asset_service/async_client.py | 12 +- .../services/asset_service/async_client.py | 30 ++--- .../services/asset_service/async_client.py | 12 +- .../services/asset_service/async_client.py | 6 +- .../unit/gapic/asset_v1/test_asset_service.py | 110 +++++++++--------- .../asset_v1p1beta1/test_asset_service.py | 20 ++-- .../asset_v1p2beta1/test_asset_service.py | 40 +++---- .../asset_v1p4beta1/test_asset_service.py | 16 +-- .../asset_v1p5beta1/test_asset_service.py | 10 +- 10 files changed, 167 insertions(+), 167 deletions(-) diff --git a/google/cloud/asset_v1/services/asset_service/async_client.py b/google/cloud/asset_v1/services/asset_service/async_client.py index 12f69e51..6c63892d 100644 --- a/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1/services/asset_service/async_client.py @@ -240,9 +240,9 @@ async def export_assets( from google.cloud import asset_v1 - def sample_export_assets(): + async def sample_export_assets(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) output_config = asset_v1.OutputConfig() @@ -258,7 +258,7 @@ def sample_export_assets(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -335,9 +335,9 @@ async def list_assets( from google.cloud import asset_v1 - def sample_list_assets(): + async def sample_list_assets(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.ListAssetsRequest( @@ -348,7 +348,7 @@ def sample_list_assets(): page_result = client.list_assets(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -459,9 +459,9 @@ async def batch_get_assets_history( from google.cloud import asset_v1 - def sample_batch_get_assets_history(): + async def sample_batch_get_assets_history(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.BatchGetAssetsHistoryRequest( @@ -469,7 +469,7 @@ def sample_batch_get_assets_history(): ) # Make the request - response = client.batch_get_assets_history(request=request) + response = await client.batch_get_assets_history(request=request) # Handle the response print(response) @@ -542,9 +542,9 @@ async def create_feed( from google.cloud import asset_v1 - def sample_create_feed(): + async def sample_create_feed(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) feed = asset_v1.Feed() @@ -557,7 +557,7 @@ def sample_create_feed(): ) # Make the request - response = client.create_feed(request=request) + response = await client.create_feed(request=request) # Handle the response print(response) @@ -653,9 +653,9 @@ async def get_feed( from google.cloud import asset_v1 - def sample_get_feed(): + async def sample_get_feed(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.GetFeedRequest( @@ -663,7 +663,7 @@ def sample_get_feed(): ) # Make the request - response = client.get_feed(request=request) + response = await client.get_feed(request=request) # Handle the response print(response) @@ -765,9 +765,9 @@ async def list_feeds( from google.cloud import asset_v1 - def sample_list_feeds(): + async def sample_list_feeds(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.ListFeedsRequest( @@ -775,7 +775,7 @@ def sample_list_feeds(): ) # Make the request - response = client.list_feeds(request=request) + response = await client.list_feeds(request=request) # Handle the response print(response) @@ -871,9 +871,9 @@ async def update_feed( from google.cloud import asset_v1 - def sample_update_feed(): + async def sample_update_feed(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) feed = asset_v1.Feed() @@ -884,7 +884,7 @@ def sample_update_feed(): ) # Make the request - response = client.update_feed(request=request) + response = await client.update_feed(request=request) # Handle the response print(response) @@ -978,9 +978,9 @@ async def delete_feed( from google.cloud import asset_v1 - def sample_delete_feed(): + async def sample_delete_feed(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.DeleteFeedRequest( @@ -988,7 +988,7 @@ def sample_delete_feed(): ) # Make the request - client.delete_feed(request=request) + await client.delete_feed(request=request) Args: request (Union[google.cloud.asset_v1.types.DeleteFeedRequest, dict]): @@ -1077,9 +1077,9 @@ async def search_all_resources( from google.cloud import asset_v1 - def sample_search_all_resources(): + async def sample_search_all_resources(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.SearchAllResourcesRequest( @@ -1090,7 +1090,7 @@ def sample_search_all_resources(): page_result = client.search_all_resources(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1286,9 +1286,9 @@ async def search_all_iam_policies( from google.cloud import asset_v1 - def sample_search_all_iam_policies(): + async def sample_search_all_iam_policies(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.SearchAllIamPoliciesRequest( @@ -1299,7 +1299,7 @@ def sample_search_all_iam_policies(): page_result = client.search_all_iam_policies(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1471,9 +1471,9 @@ async def analyze_iam_policy( from google.cloud import asset_v1 - def sample_analyze_iam_policy(): + async def sample_analyze_iam_policy(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) analysis_query = asset_v1.IamPolicyAnalysisQuery() @@ -1484,7 +1484,7 @@ def sample_analyze_iam_policy(): ) # Make the request - response = client.analyze_iam_policy(request=request) + response = await client.analyze_iam_policy(request=request) # Handle the response print(response) @@ -1569,9 +1569,9 @@ async def analyze_iam_policy_longrunning( from google.cloud import asset_v1 - def sample_analyze_iam_policy_longrunning(): + async def sample_analyze_iam_policy_longrunning(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) analysis_query = asset_v1.IamPolicyAnalysisQuery() @@ -1590,7 +1590,7 @@ def sample_analyze_iam_policy_longrunning(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1673,9 +1673,9 @@ async def analyze_move( from google.cloud import asset_v1 - def sample_analyze_move(): + async def sample_analyze_move(): # Create a client - client = asset_v1.AssetServiceClient() + client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1.AnalyzeMoveRequest( @@ -1684,7 +1684,7 @@ def sample_analyze_move(): ) # Make the request - response = client.analyze_move(request=request) + response = await client.analyze_move(request=request) # Handle the response print(response) diff --git a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py index da3db720..c69a2785 100644 --- a/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py @@ -220,9 +220,9 @@ async def search_all_resources( from google.cloud import asset_v1p1beta1 - def sample_search_all_resources(): + async def sample_search_all_resources(): # Create a client - client = asset_v1p1beta1.AssetServiceClient() + client = asset_v1p1beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p1beta1.SearchAllResourcesRequest( @@ -233,7 +233,7 @@ def sample_search_all_resources(): page_result = client.search_all_resources(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -368,9 +368,9 @@ async def search_all_iam_policies( from google.cloud import asset_v1p1beta1 - def sample_search_all_iam_policies(): + async def sample_search_all_iam_policies(): # Create a client - client = asset_v1p1beta1.AssetServiceClient() + client = asset_v1p1beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p1beta1.SearchAllIamPoliciesRequest( @@ -381,7 +381,7 @@ def sample_search_all_iam_policies(): page_result = client.search_all_iam_policies(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: diff --git a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py index c14b44d7..713e8359 100644 --- a/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py @@ -214,9 +214,9 @@ async def create_feed( from google.cloud import asset_v1p2beta1 - def sample_create_feed(): + async def sample_create_feed(): # Create a client - client = asset_v1p2beta1.AssetServiceClient() + client = asset_v1p2beta1.AssetServiceAsyncClient() # Initialize request argument(s) feed = asset_v1p2beta1.Feed() @@ -229,7 +229,7 @@ def sample_create_feed(): ) # Make the request - response = client.create_feed(request=request) + response = await client.create_feed(request=request) # Handle the response print(response) @@ -325,9 +325,9 @@ async def get_feed( from google.cloud import asset_v1p2beta1 - def sample_get_feed(): + async def sample_get_feed(): # Create a client - client = asset_v1p2beta1.AssetServiceClient() + client = asset_v1p2beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p2beta1.GetFeedRequest( @@ -335,7 +335,7 @@ def sample_get_feed(): ) # Make the request - response = client.get_feed(request=request) + response = await client.get_feed(request=request) # Handle the response print(response) @@ -437,9 +437,9 @@ async def list_feeds( from google.cloud import asset_v1p2beta1 - def sample_list_feeds(): + async def sample_list_feeds(): # Create a client - client = asset_v1p2beta1.AssetServiceClient() + client = asset_v1p2beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p2beta1.ListFeedsRequest( @@ -447,7 +447,7 @@ def sample_list_feeds(): ) # Make the request - response = client.list_feeds(request=request) + response = await client.list_feeds(request=request) # Handle the response print(response) @@ -543,9 +543,9 @@ async def update_feed( from google.cloud import asset_v1p2beta1 - def sample_update_feed(): + async def sample_update_feed(): # Create a client - client = asset_v1p2beta1.AssetServiceClient() + client = asset_v1p2beta1.AssetServiceAsyncClient() # Initialize request argument(s) feed = asset_v1p2beta1.Feed() @@ -556,7 +556,7 @@ def sample_update_feed(): ) # Make the request - response = client.update_feed(request=request) + response = await client.update_feed(request=request) # Handle the response print(response) @@ -650,9 +650,9 @@ async def delete_feed( from google.cloud import asset_v1p2beta1 - def sample_delete_feed(): + async def sample_delete_feed(): # Create a client - client = asset_v1p2beta1.AssetServiceClient() + client = asset_v1p2beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p2beta1.DeleteFeedRequest( @@ -660,7 +660,7 @@ def sample_delete_feed(): ) # Make the request - client.delete_feed(request=request) + await client.delete_feed(request=request) Args: request (Union[google.cloud.asset_v1p2beta1.types.DeleteFeedRequest, dict]): diff --git a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py index ad50c3a7..6c8d90af 100644 --- a/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p4beta1/services/asset_service/async_client.py @@ -215,9 +215,9 @@ async def analyze_iam_policy( from google.cloud import asset_v1p4beta1 - def sample_analyze_iam_policy(): + async def sample_analyze_iam_policy(): # Create a client - client = asset_v1p4beta1.AssetServiceClient() + client = asset_v1p4beta1.AssetServiceAsyncClient() # Initialize request argument(s) analysis_query = asset_v1p4beta1.IamPolicyAnalysisQuery() @@ -228,7 +228,7 @@ def sample_analyze_iam_policy(): ) # Make the request - response = client.analyze_iam_policy(request=request) + response = await client.analyze_iam_policy(request=request) # Handle the response print(response) @@ -306,9 +306,9 @@ async def export_iam_policy_analysis( from google.cloud import asset_v1p4beta1 - def sample_export_iam_policy_analysis(): + async def sample_export_iam_policy_analysis(): # Create a client - client = asset_v1p4beta1.AssetServiceClient() + client = asset_v1p4beta1.AssetServiceAsyncClient() # Initialize request argument(s) analysis_query = asset_v1p4beta1.IamPolicyAnalysisQuery() @@ -327,7 +327,7 @@ def sample_export_iam_policy_analysis(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index 1d24e0a7..3b1368d8 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py @@ -222,9 +222,9 @@ async def list_assets( from google.cloud import asset_v1p5beta1 - def sample_list_assets(): + async def sample_list_assets(): # Create a client - client = asset_v1p5beta1.AssetServiceClient() + client = asset_v1p5beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p5beta1.ListAssetsRequest( @@ -235,7 +235,7 @@ def sample_list_assets(): page_result = client.list_assets(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: diff --git a/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/unit/gapic/asset_v1/test_asset_service.py index 3dabd1d3..642cb700 100644 --- a/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1/test_asset_service.py @@ -734,7 +734,7 @@ def test_export_assets_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ExportAssetsRequest() - 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.export_assets), "__call__") as call: @@ -750,7 +750,7 @@ def test_export_assets_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -764,7 +764,7 @@ async def test_export_assets_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ExportAssetsRequest() - 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.export_assets), "__call__") as call: @@ -782,7 +782,7 @@ async def test_export_assets_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -884,7 +884,7 @@ def test_list_assets_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ListAssetsRequest() - 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_assets), "__call__") as call: @@ -900,7 +900,7 @@ def test_list_assets_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -914,7 +914,7 @@ async def test_list_assets_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ListAssetsRequest() - 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_assets), "__call__") as call: @@ -932,7 +932,7 @@ async def test_list_assets_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1063,7 +1063,7 @@ def test_list_assets_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.Asset) for i in results) @@ -1305,7 +1305,7 @@ def test_batch_get_assets_history_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.BatchGetAssetsHistoryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1323,7 +1323,7 @@ def test_batch_get_assets_history_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1337,7 +1337,7 @@ async def test_batch_get_assets_history_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.BatchGetAssetsHistoryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1357,7 +1357,7 @@ async def test_batch_get_assets_history_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1475,7 +1475,7 @@ def test_create_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.CreateFeedRequest() - 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_feed), "__call__") as call: @@ -1491,7 +1491,7 @@ def test_create_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1505,7 +1505,7 @@ async def test_create_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.CreateFeedRequest() - 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_feed), "__call__") as call: @@ -1521,7 +1521,7 @@ async def test_create_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1719,7 +1719,7 @@ def test_get_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.GetFeedRequest() - 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_feed), "__call__") as call: @@ -1735,7 +1735,7 @@ def test_get_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1749,7 +1749,7 @@ async def test_get_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.GetFeedRequest() - 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_feed), "__call__") as call: @@ -1765,7 +1765,7 @@ async def test_get_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1941,7 +1941,7 @@ def test_list_feeds_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ListFeedsRequest() - 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_feeds), "__call__") as call: @@ -1957,7 +1957,7 @@ def test_list_feeds_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1971,7 +1971,7 @@ async def test_list_feeds_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ListFeedsRequest() - 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_feeds), "__call__") as call: @@ -1989,7 +1989,7 @@ async def test_list_feeds_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2189,7 +2189,7 @@ def test_update_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.UpdateFeedRequest() - request.feed.name = "feed.name/value" + request.feed.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -2205,7 +2205,7 @@ def test_update_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "feed.name=feed.name/value", + "feed.name=name_value", ) in kw["metadata"] @@ -2219,7 +2219,7 @@ async def test_update_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.UpdateFeedRequest() - request.feed.name = "feed.name/value" + request.feed.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -2235,7 +2235,7 @@ async def test_update_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "feed.name=feed.name/value", + "feed.name=name_value", ) in kw["metadata"] @@ -2409,7 +2409,7 @@ def test_delete_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.DeleteFeedRequest() - 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_feed), "__call__") as call: @@ -2425,7 +2425,7 @@ def test_delete_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2439,7 +2439,7 @@ async def test_delete_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.DeleteFeedRequest() - 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_feed), "__call__") as call: @@ -2455,7 +2455,7 @@ async def test_delete_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2644,7 +2644,7 @@ def test_search_all_resources_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllResourcesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2662,7 +2662,7 @@ def test_search_all_resources_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -2676,7 +2676,7 @@ async def test_search_all_resources_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllResourcesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2696,7 +2696,7 @@ async def test_search_all_resources_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -2853,7 +2853,7 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.ResourceSearchResult) for i in results) @@ -3107,7 +3107,7 @@ def test_search_all_iam_policies_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllIamPoliciesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3125,7 +3125,7 @@ def test_search_all_iam_policies_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -3139,7 +3139,7 @@ async def test_search_all_iam_policies_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllIamPoliciesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3159,7 +3159,7 @@ async def test_search_all_iam_policies_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -3306,7 +3306,7 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.IamPolicySearchResult) for i in results) @@ -3559,7 +3559,7 @@ def test_analyze_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyRequest() - request.analysis_query.scope = "analysis_query.scope/value" + request.analysis_query.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3577,7 +3577,7 @@ def test_analyze_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.scope=analysis_query.scope/value", + "analysis_query.scope=scope_value", ) in kw["metadata"] @@ -3591,7 +3591,7 @@ async def test_analyze_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyRequest() - request.analysis_query.scope = "analysis_query.scope/value" + request.analysis_query.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3611,7 +3611,7 @@ async def test_analyze_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.scope=analysis_query.scope/value", + "analysis_query.scope=scope_value", ) in kw["metadata"] @@ -3714,7 +3714,7 @@ def test_analyze_iam_policy_longrunning_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyLongrunningRequest() - request.analysis_query.scope = "analysis_query.scope/value" + request.analysis_query.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3732,7 +3732,7 @@ def test_analyze_iam_policy_longrunning_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.scope=analysis_query.scope/value", + "analysis_query.scope=scope_value", ) in kw["metadata"] @@ -3746,7 +3746,7 @@ async def test_analyze_iam_policy_longrunning_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyLongrunningRequest() - request.analysis_query.scope = "analysis_query.scope/value" + request.analysis_query.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3766,7 +3766,7 @@ async def test_analyze_iam_policy_longrunning_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.scope=analysis_query.scope/value", + "analysis_query.scope=scope_value", ) in kw["metadata"] @@ -3862,7 +3862,7 @@ def test_analyze_move_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeMoveRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.analyze_move), "__call__") as call: @@ -3878,7 +3878,7 @@ def test_analyze_move_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -3892,7 +3892,7 @@ async def test_analyze_move_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeMoveRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.analyze_move), "__call__") as call: @@ -3910,7 +3910,7 @@ async def test_analyze_move_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py index d8199fbe..24f28a8f 100644 --- a/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py @@ -738,7 +738,7 @@ def test_search_all_resources_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllResourcesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -756,7 +756,7 @@ def test_search_all_resources_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -770,7 +770,7 @@ async def test_search_all_resources_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllResourcesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -790,7 +790,7 @@ async def test_search_all_resources_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -947,7 +947,7 @@ def test_search_all_resources_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.StandardResourceMetadata) for i in results) @@ -1201,7 +1201,7 @@ def test_search_all_iam_policies_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllIamPoliciesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1219,7 +1219,7 @@ def test_search_all_iam_policies_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -1233,7 +1233,7 @@ async def test_search_all_iam_policies_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.SearchAllIamPoliciesRequest() - request.scope = "scope/value" + request.scope = "scope_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1253,7 +1253,7 @@ async def test_search_all_iam_policies_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "scope=scope/value", + "scope=scope_value", ) in kw["metadata"] @@ -1400,7 +1400,7 @@ def test_search_all_iam_policies_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.IamPolicySearchResult) for i in results) diff --git a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py index 5e0e9bc8..13daf9dd 100644 --- a/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py @@ -742,7 +742,7 @@ def test_create_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.CreateFeedRequest() - 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_feed), "__call__") as call: @@ -758,7 +758,7 @@ def test_create_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -772,7 +772,7 @@ async def test_create_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.CreateFeedRequest() - 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_feed), "__call__") as call: @@ -788,7 +788,7 @@ async def test_create_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -982,7 +982,7 @@ def test_get_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.GetFeedRequest() - 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_feed), "__call__") as call: @@ -998,7 +998,7 @@ def test_get_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1012,7 +1012,7 @@ async def test_get_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.GetFeedRequest() - 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_feed), "__call__") as call: @@ -1028,7 +1028,7 @@ async def test_get_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1204,7 +1204,7 @@ def test_list_feeds_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ListFeedsRequest() - 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_feeds), "__call__") as call: @@ -1220,7 +1220,7 @@ def test_list_feeds_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1234,7 +1234,7 @@ async def test_list_feeds_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ListFeedsRequest() - 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_feeds), "__call__") as call: @@ -1252,7 +1252,7 @@ async def test_list_feeds_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1448,7 +1448,7 @@ def test_update_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.UpdateFeedRequest() - request.feed.name = "feed.name/value" + request.feed.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -1464,7 +1464,7 @@ def test_update_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "feed.name=feed.name/value", + "feed.name=name_value", ) in kw["metadata"] @@ -1478,7 +1478,7 @@ async def test_update_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.UpdateFeedRequest() - request.feed.name = "feed.name/value" + request.feed.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feed), "__call__") as call: @@ -1494,7 +1494,7 @@ async def test_update_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "feed.name=feed.name/value", + "feed.name=name_value", ) in kw["metadata"] @@ -1668,7 +1668,7 @@ def test_delete_feed_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.DeleteFeedRequest() - 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_feed), "__call__") as call: @@ -1684,7 +1684,7 @@ def test_delete_feed_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1698,7 +1698,7 @@ async def test_delete_feed_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.DeleteFeedRequest() - 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_feed), "__call__") as call: @@ -1714,7 +1714,7 @@ async def test_delete_feed_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py index 3c8c9efb..7c044a0b 100644 --- a/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p4beta1/test_asset_service.py @@ -742,7 +742,7 @@ def test_analyze_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyRequest() - request.analysis_query.parent = "analysis_query.parent/value" + request.analysis_query.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -760,7 +760,7 @@ def test_analyze_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.parent=analysis_query.parent/value", + "analysis_query.parent=parent_value", ) in kw["metadata"] @@ -774,7 +774,7 @@ async def test_analyze_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.AnalyzeIamPolicyRequest() - request.analysis_query.parent = "analysis_query.parent/value" + request.analysis_query.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -794,7 +794,7 @@ async def test_analyze_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.parent=analysis_query.parent/value", + "analysis_query.parent=parent_value", ) in kw["metadata"] @@ -897,7 +897,7 @@ def test_export_iam_policy_analysis_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ExportIamPolicyAnalysisRequest() - request.analysis_query.parent = "analysis_query.parent/value" + request.analysis_query.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -915,7 +915,7 @@ def test_export_iam_policy_analysis_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.parent=analysis_query.parent/value", + "analysis_query.parent=parent_value", ) in kw["metadata"] @@ -929,7 +929,7 @@ async def test_export_iam_policy_analysis_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ExportIamPolicyAnalysisRequest() - request.analysis_query.parent = "analysis_query.parent/value" + request.analysis_query.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -949,7 +949,7 @@ async def test_export_iam_policy_analysis_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "analysis_query.parent=analysis_query.parent/value", + "analysis_query.parent=parent_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index 16d34971..7d6afc47 100644 --- a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -732,7 +732,7 @@ def test_list_assets_field_headers(): # a field header. Set these to a non-empty value. request = asset_service.ListAssetsRequest() - 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_assets), "__call__") as call: @@ -748,7 +748,7 @@ def test_list_assets_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -762,7 +762,7 @@ async def test_list_assets_field_headers_async(): # a field header. Set these to a non-empty value. request = asset_service.ListAssetsRequest() - 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_assets), "__call__") as call: @@ -780,7 +780,7 @@ async def test_list_assets_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -829,7 +829,7 @@ def test_list_assets_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, assets.Asset) for i in results) From 67a258fcf6feb1ec24d31cd8186bcc89156ebadb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 27 Apr 2022 19:30:41 +0200 Subject: [PATCH 24/30] chore(deps): update dependency backoff to v2.0.1 (#419) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index a443e90a..c78317e3 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==2.0.0 +backoff==2.0.1 flaky==3.7.0 pytest==7.1.2 From ced2096e13f288e2751de21796f6baf2bcf9a247 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 12:13:40 -0400 Subject: [PATCH 25/30] chore: [autoapprove] update readme_gen.py to include autoescape True (#420) Source-Link: https://github.com/googleapis/synthtool/commit/6b4d5a6407d740beb4158b302194a62a4108a8a6 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- scripts/readme-gen/readme_gen.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 64f82d6b..b631901e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd -# created: 2022-04-21T15:43:16.246106921Z + digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 +# created: 2022-05-05T15:17:27.599381182Z diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e9..91b59676 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') From 82a42ad20ce8cfb8968ead81c5476248ea253610 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 22:58:30 +0000 Subject: [PATCH 26/30] chore(python): auto approve template changes (#422) Source-Link: https://github.com/googleapis/synthtool/commit/453a5d9c9a55d1969240a37d36cec626d20a9024 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-approve.yml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .github/auto-approve.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index b631901e..757c9dca 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 -# created: 2022-05-05T15:17:27.599381182Z + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 00000000..311ebbb8 --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" From 322877fcd67965924bd346148fbabb9a40b92ff4 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 9 May 2022 22:15:21 +0200 Subject: [PATCH 27/30] chore(deps): update dependency google-cloud-bigquery to v3.1.0 (#423) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 14b02476..e8bcdeed 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -2,4 +2,4 @@ google-cloud-storage==2.3.0 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 google-cloud-pubsub==2.12.0 -google-cloud-bigquery==3.0.1 +google-cloud-bigquery==3.1.0 From 0131204674af9559618572f981ad07a4d4b58a75 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 12 May 2022 20:17:07 +0200 Subject: [PATCH 28/30] chore(deps): update dependency google-cloud-pubsub to v2.12.1 (#424) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index e8bcdeed..317e277e 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,5 +1,5 @@ google-cloud-storage==2.3.0 google-cloud-asset==3.8.1 google-cloud-resource-manager==1.4.1 -google-cloud-pubsub==2.12.0 +google-cloud-pubsub==2.12.1 google-cloud-bigquery==3.1.0 From b3e5650732e46c4c6ee7835cdfa38c1232efb3b9 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 12:12:12 +0000 Subject: [PATCH 29/30] feat: Add SavedQuery CURD support (#425) - [ ] Regenerate this pull request now. feat: Add tags support feat: Add RelatedAsset and deprecate RelatedAssets for relationship GA *The previous representation of the relationship feature is deprecated and unimplemented. The RelatedAsset message represents the new stable format. PiperOrigin-RevId: 449306805 Source-Link: https://github.com/googleapis/googleapis/commit/3d7bd9d4a8772e0c7e1d39a2763e1914bfb5963d Source-Link: https://github.com/googleapis/googleapis-gen/commit/71a93d05d6076271d04b7592f7fad0d3f0c7a040 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzFhOTNkMDVkNjA3NjI3MWQwNGI3NTkyZjdmYWQwZDNmMGM3YTA0MCJ9 --- google/cloud/asset/__init__.py | 22 + google/cloud/asset_v1/__init__.py | 18 + google/cloud/asset_v1/gapic_metadata.json | 60 + .../services/asset_service/async_client.py | 650 ++++++- .../asset_v1/services/asset_service/client.py | 670 ++++++- .../asset_v1/services/asset_service/pagers.py | 128 ++ .../services/asset_service/transports/base.py | 90 + .../services/asset_service/transports/grpc.py | 172 +- .../asset_service/transports/grpc_asyncio.py | 179 +- google/cloud/asset_v1/types/__init__.py | 18 + google/cloud/asset_v1/types/asset_service.py | 557 +++++- google/cloud/asset_v1/types/assets.py | 107 +- ..._batch_get_effective_iam_policies_async.py | 46 + ...e_batch_get_effective_iam_policies_sync.py | 46 + ..._asset_service_create_saved_query_async.py | 46 + ...d_asset_service_create_saved_query_sync.py | 46 + ..._asset_service_delete_saved_query_async.py | 43 + ...d_asset_service_delete_saved_query_sync.py | 43 + ...ted_asset_service_get_saved_query_async.py | 45 + ...ated_asset_service_get_saved_query_sync.py | 45 + ..._asset_service_list_saved_queries_async.py | 46 + ...d_asset_service_list_saved_queries_sync.py | 46 + ..._asset_service_update_saved_query_async.py | 44 + ...d_asset_service_update_saved_query_sync.py | 44 + .../snippet_metadata_asset_v1.json | 1334 +++++++++++-- scripts/fixup_asset_v1_keywords.py | 10 +- .../unit/gapic/asset_v1/test_asset_service.py | 1682 ++++++++++++++++- 27 files changed, 5953 insertions(+), 284 deletions(-) create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_sync.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_sync.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_sync.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_sync.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_async.py create mode 100644 samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_sync.py diff --git a/google/cloud/asset/__init__.py b/google/cloud/asset/__init__.py index 86224474..9fd034b5 100644 --- a/google/cloud/asset/__init__.py +++ b/google/cloud/asset/__init__.py @@ -32,9 +32,17 @@ from google.cloud.asset_v1.types.asset_service import AnalyzeMoveResponse from google.cloud.asset_v1.types.asset_service import BatchGetAssetsHistoryRequest from google.cloud.asset_v1.types.asset_service import BatchGetAssetsHistoryResponse +from google.cloud.asset_v1.types.asset_service import ( + BatchGetEffectiveIamPoliciesRequest, +) +from google.cloud.asset_v1.types.asset_service import ( + BatchGetEffectiveIamPoliciesResponse, +) from google.cloud.asset_v1.types.asset_service import BigQueryDestination from google.cloud.asset_v1.types.asset_service import CreateFeedRequest +from google.cloud.asset_v1.types.asset_service import CreateSavedQueryRequest from google.cloud.asset_v1.types.asset_service import DeleteFeedRequest +from google.cloud.asset_v1.types.asset_service import DeleteSavedQueryRequest from google.cloud.asset_v1.types.asset_service import ExportAssetsRequest from google.cloud.asset_v1.types.asset_service import ExportAssetsResponse from google.cloud.asset_v1.types.asset_service import Feed @@ -42,12 +50,15 @@ from google.cloud.asset_v1.types.asset_service import GcsDestination from google.cloud.asset_v1.types.asset_service import GcsOutputResult from google.cloud.asset_v1.types.asset_service import GetFeedRequest +from google.cloud.asset_v1.types.asset_service import GetSavedQueryRequest from google.cloud.asset_v1.types.asset_service import IamPolicyAnalysisOutputConfig from google.cloud.asset_v1.types.asset_service import IamPolicyAnalysisQuery from google.cloud.asset_v1.types.asset_service import ListAssetsRequest from google.cloud.asset_v1.types.asset_service import ListAssetsResponse from google.cloud.asset_v1.types.asset_service import ListFeedsRequest from google.cloud.asset_v1.types.asset_service import ListFeedsResponse +from google.cloud.asset_v1.types.asset_service import ListSavedQueriesRequest +from google.cloud.asset_v1.types.asset_service import ListSavedQueriesResponse from google.cloud.asset_v1.types.asset_service import MoveAnalysis from google.cloud.asset_v1.types.asset_service import MoveAnalysisResult from google.cloud.asset_v1.types.asset_service import MoveImpact @@ -55,11 +66,13 @@ from google.cloud.asset_v1.types.asset_service import OutputResult from google.cloud.asset_v1.types.asset_service import PartitionSpec from google.cloud.asset_v1.types.asset_service import PubsubDestination +from google.cloud.asset_v1.types.asset_service import SavedQuery from google.cloud.asset_v1.types.asset_service import SearchAllIamPoliciesRequest from google.cloud.asset_v1.types.asset_service import SearchAllIamPoliciesResponse from google.cloud.asset_v1.types.asset_service import SearchAllResourcesRequest from google.cloud.asset_v1.types.asset_service import SearchAllResourcesResponse from google.cloud.asset_v1.types.asset_service import UpdateFeedRequest +from google.cloud.asset_v1.types.asset_service import UpdateSavedQueryRequest from google.cloud.asset_v1.types.asset_service import ContentType from google.cloud.asset_v1.types.assets import Asset from google.cloud.asset_v1.types.assets import AttachedResource @@ -90,9 +103,13 @@ "AnalyzeMoveResponse", "BatchGetAssetsHistoryRequest", "BatchGetAssetsHistoryResponse", + "BatchGetEffectiveIamPoliciesRequest", + "BatchGetEffectiveIamPoliciesResponse", "BigQueryDestination", "CreateFeedRequest", + "CreateSavedQueryRequest", "DeleteFeedRequest", + "DeleteSavedQueryRequest", "ExportAssetsRequest", "ExportAssetsResponse", "Feed", @@ -100,12 +117,15 @@ "GcsDestination", "GcsOutputResult", "GetFeedRequest", + "GetSavedQueryRequest", "IamPolicyAnalysisOutputConfig", "IamPolicyAnalysisQuery", "ListAssetsRequest", "ListAssetsResponse", "ListFeedsRequest", "ListFeedsResponse", + "ListSavedQueriesRequest", + "ListSavedQueriesResponse", "MoveAnalysis", "MoveAnalysisResult", "MoveImpact", @@ -113,11 +133,13 @@ "OutputResult", "PartitionSpec", "PubsubDestination", + "SavedQuery", "SearchAllIamPoliciesRequest", "SearchAllIamPoliciesResponse", "SearchAllResourcesRequest", "SearchAllResourcesResponse", "UpdateFeedRequest", + "UpdateSavedQueryRequest", "ContentType", "Asset", "AttachedResource", diff --git a/google/cloud/asset_v1/__init__.py b/google/cloud/asset_v1/__init__.py index e3b64ace..6101e0e7 100644 --- a/google/cloud/asset_v1/__init__.py +++ b/google/cloud/asset_v1/__init__.py @@ -26,9 +26,13 @@ from .types.asset_service import AnalyzeMoveResponse from .types.asset_service import BatchGetAssetsHistoryRequest from .types.asset_service import BatchGetAssetsHistoryResponse +from .types.asset_service import BatchGetEffectiveIamPoliciesRequest +from .types.asset_service import BatchGetEffectiveIamPoliciesResponse from .types.asset_service import BigQueryDestination from .types.asset_service import CreateFeedRequest +from .types.asset_service import CreateSavedQueryRequest from .types.asset_service import DeleteFeedRequest +from .types.asset_service import DeleteSavedQueryRequest from .types.asset_service import ExportAssetsRequest from .types.asset_service import ExportAssetsResponse from .types.asset_service import Feed @@ -36,12 +40,15 @@ from .types.asset_service import GcsDestination from .types.asset_service import GcsOutputResult from .types.asset_service import GetFeedRequest +from .types.asset_service import GetSavedQueryRequest from .types.asset_service import IamPolicyAnalysisOutputConfig from .types.asset_service import IamPolicyAnalysisQuery from .types.asset_service import ListAssetsRequest from .types.asset_service import ListAssetsResponse from .types.asset_service import ListFeedsRequest from .types.asset_service import ListFeedsResponse +from .types.asset_service import ListSavedQueriesRequest +from .types.asset_service import ListSavedQueriesResponse from .types.asset_service import MoveAnalysis from .types.asset_service import MoveAnalysisResult from .types.asset_service import MoveImpact @@ -49,11 +56,13 @@ from .types.asset_service import OutputResult from .types.asset_service import PartitionSpec from .types.asset_service import PubsubDestination +from .types.asset_service import SavedQuery from .types.asset_service import SearchAllIamPoliciesRequest from .types.asset_service import SearchAllIamPoliciesResponse from .types.asset_service import SearchAllResourcesRequest from .types.asset_service import SearchAllResourcesResponse from .types.asset_service import UpdateFeedRequest +from .types.asset_service import UpdateSavedQueryRequest from .types.asset_service import ContentType from .types.assets import Asset from .types.assets import AttachedResource @@ -86,11 +95,15 @@ "AttachedResource", "BatchGetAssetsHistoryRequest", "BatchGetAssetsHistoryResponse", + "BatchGetEffectiveIamPoliciesRequest", + "BatchGetEffectiveIamPoliciesResponse", "BigQueryDestination", "ConditionEvaluation", "ContentType", "CreateFeedRequest", + "CreateSavedQueryRequest", "DeleteFeedRequest", + "DeleteSavedQueryRequest", "ExportAssetsRequest", "ExportAssetsResponse", "Feed", @@ -98,6 +111,7 @@ "GcsDestination", "GcsOutputResult", "GetFeedRequest", + "GetSavedQueryRequest", "IamPolicyAnalysisOutputConfig", "IamPolicyAnalysisQuery", "IamPolicyAnalysisResult", @@ -107,6 +121,8 @@ "ListAssetsResponse", "ListFeedsRequest", "ListFeedsResponse", + "ListSavedQueriesRequest", + "ListSavedQueriesResponse", "MoveAnalysis", "MoveAnalysisResult", "MoveImpact", @@ -121,6 +137,7 @@ "RelationshipAttributes", "Resource", "ResourceSearchResult", + "SavedQuery", "SearchAllIamPoliciesRequest", "SearchAllIamPoliciesResponse", "SearchAllResourcesRequest", @@ -128,5 +145,6 @@ "TemporalAsset", "TimeWindow", "UpdateFeedRequest", + "UpdateSavedQueryRequest", "VersionedResource", ) diff --git a/google/cloud/asset_v1/gapic_metadata.json b/google/cloud/asset_v1/gapic_metadata.json index dea0335c..b0acb181 100644 --- a/google/cloud/asset_v1/gapic_metadata.json +++ b/google/cloud/asset_v1/gapic_metadata.json @@ -30,16 +30,31 @@ "batch_get_assets_history" ] }, + "BatchGetEffectiveIamPolicies": { + "methods": [ + "batch_get_effective_iam_policies" + ] + }, "CreateFeed": { "methods": [ "create_feed" ] }, + "CreateSavedQuery": { + "methods": [ + "create_saved_query" + ] + }, "DeleteFeed": { "methods": [ "delete_feed" ] }, + "DeleteSavedQuery": { + "methods": [ + "delete_saved_query" + ] + }, "ExportAssets": { "methods": [ "export_assets" @@ -50,6 +65,11 @@ "get_feed" ] }, + "GetSavedQuery": { + "methods": [ + "get_saved_query" + ] + }, "ListAssets": { "methods": [ "list_assets" @@ -60,6 +80,11 @@ "list_feeds" ] }, + "ListSavedQueries": { + "methods": [ + "list_saved_queries" + ] + }, "SearchAllIamPolicies": { "methods": [ "search_all_iam_policies" @@ -74,6 +99,11 @@ "methods": [ "update_feed" ] + }, + "UpdateSavedQuery": { + "methods": [ + "update_saved_query" + ] } } }, @@ -100,16 +130,31 @@ "batch_get_assets_history" ] }, + "BatchGetEffectiveIamPolicies": { + "methods": [ + "batch_get_effective_iam_policies" + ] + }, "CreateFeed": { "methods": [ "create_feed" ] }, + "CreateSavedQuery": { + "methods": [ + "create_saved_query" + ] + }, "DeleteFeed": { "methods": [ "delete_feed" ] }, + "DeleteSavedQuery": { + "methods": [ + "delete_saved_query" + ] + }, "ExportAssets": { "methods": [ "export_assets" @@ -120,6 +165,11 @@ "get_feed" ] }, + "GetSavedQuery": { + "methods": [ + "get_saved_query" + ] + }, "ListAssets": { "methods": [ "list_assets" @@ -130,6 +180,11 @@ "list_feeds" ] }, + "ListSavedQueries": { + "methods": [ + "list_saved_queries" + ] + }, "SearchAllIamPolicies": { "methods": [ "search_all_iam_policies" @@ -144,6 +199,11 @@ "methods": [ "update_feed" ] + }, + "UpdateSavedQuery": { + "methods": [ + "update_saved_query" + ] } } } diff --git a/google/cloud/asset_v1/services/asset_service/async_client.py b/google/cloud/asset_v1/services/asset_service/async_client.py index 6c63892d..be0002d8 100644 --- a/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1/services/asset_service/async_client.py @@ -36,6 +36,8 @@ from google.cloud.asset_v1.services.asset_service import pagers from google.cloud.asset_v1.types import asset_service from google.cloud.asset_v1.types import assets +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 from .transports.base import AssetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import AssetServiceGrpcAsyncIOTransport @@ -60,6 +62,8 @@ class AssetServiceAsyncClient: parse_feed_path = staticmethod(AssetServiceClient.parse_feed_path) inventory_path = staticmethod(AssetServiceClient.inventory_path) parse_inventory_path = staticmethod(AssetServiceClient.parse_inventory_path) + saved_query_path = staticmethod(AssetServiceClient.saved_query_path) + parse_saved_query_path = staticmethod(AssetServiceClient.parse_saved_query_path) service_perimeter_path = staticmethod(AssetServiceClient.service_perimeter_path) parse_service_perimeter_path = staticmethod( AssetServiceClient.parse_service_perimeter_path @@ -228,10 +232,10 @@ async def export_assets( line represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for BigQuery table destinations, the output - table stores the fields in asset proto as columns. This API + table stores the fields in asset Protobuf as columns. This API implements the - [google.longrunning.Operation][google.longrunning.Operation] API - , which allows you to keep track of the export. We recommend + [google.longrunning.Operation][google.longrunning.Operation] + API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. @@ -355,11 +359,13 @@ async def sample_list_assets(): request (Union[google.cloud.asset_v1.types.ListAssetsRequest, dict]): The request object. ListAssets request. parent (:class:`str`): - Required. Name of the organization or project the assets - belong to. Format: "organizations/[organization-number]" - (such as "organizations/123"), "projects/[project-id]" - (such as "projects/my-project-id"), or - "projects/[project-number]" (such as "projects/12345"). + Required. Name of the organization, folder, or project + the assets belong to. Format: + "organizations/[organization-number]" (such as + "organizations/123"), "projects/[project-id]" (such as + "projects/my-project-id"), "projects/[project-number]" + (such as "projects/12345"), or "folders/[folder-number]" + (such as "folders/12345"). This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -1330,10 +1336,10 @@ async def sample_search_all_iam_policies(): search all the IAM policies within the specified ``scope``. Note that the query string is compared against each Cloud IAM policy binding, including its - members, roles, and Cloud IAM conditions. The returned - Cloud IAM policies will only contain the bindings that - match your query. To learn more about the IAM policy - structure, see `IAM policy + principals, roles, and Cloud IAM conditions. The + returned Cloud IAM policies will only contain the + bindings that match your query. To learn more about the + IAM policy structure, see `IAM policy doc `__. Examples: @@ -1375,7 +1381,7 @@ async def sample_search_all_iam_policies(): - ``roles:roles/compute.admin`` to find IAM policy bindings that specify the Compute Admin role. - ``memberTypes:user`` to find IAM policy bindings that - contain the "user" member type. + contain the principal type "user". This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this @@ -1502,7 +1508,7 @@ async def sample_analyze_iam_policy(): Returns: google.cloud.asset_v1.types.AnalyzeIamPolicyResponse: A response message for - [AssetService.AnalyzeIamPolicy][google.cloud.asset.v1.AssetService.AnalyzeIamPolicy]. + [AssetService.AnalyzeIamPolicy][google.cloud.asset.v1.AssetService.AnalyzeIamPolicy]. """ # Create or coerce a protobuf request object. @@ -1609,10 +1615,8 @@ async def sample_analyze_iam_policy_longrunning(): google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be - :class:`google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningResponse` - A response message for - [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning]. + The result type for the operation will be :class:`google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningResponse` A response message for + [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning]. """ # Create or coerce a protobuf request object. @@ -1733,6 +1737,616 @@ async def sample_analyze_move(): # Done; return the response. return response + async def create_saved_query( + self, + request: Union[asset_service.CreateSavedQueryRequest, dict] = None, + *, + parent: str = None, + saved_query: asset_service.SavedQuery = None, + saved_query_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Creates a saved query in a parent + project/folder/organization. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_create_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.CreateSavedQueryRequest( + parent="parent_value", + saved_query_id="saved_query_id_value", + ) + + # Make the request + response = await client.create_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.CreateSavedQueryRequest, dict]): + The request object. Request to create a saved query. + parent (:class:`str`): + Required. The name of the project/folder/organization + where this saved_query should be created in. It can only + be an organization number (such as "organizations/123"), + a folder number (such as "folders/123"), a project ID + (such as "projects/my-project-id")", or a project number + (such as "projects/12345"). + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + saved_query (:class:`google.cloud.asset_v1.types.SavedQuery`): + Required. The saved_query details. The ``name`` field + must be empty as it will be generated based on the + parent and saved_query_id. + + This corresponds to the ``saved_query`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + saved_query_id (:class:`str`): + Required. The ID to use for the saved query, which must + be unique in the specified parent. It will become the + final component of the saved query's resource name. + + This value should be 4-63 characters, and valid + characters are /[a-z][0-9]-/. + + Notice that this field is required in the saved query + creation, and the ``name`` field of the ``saved_query`` + will be ignored. + + This corresponds to the ``saved_query_id`` 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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, saved_query, saved_query_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = asset_service.CreateSavedQueryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if saved_query is not None: + request.saved_query = saved_query + if saved_query_id is not None: + request.saved_query_id = saved_query_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_saved_query, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_saved_query( + self, + request: Union[asset_service.GetSavedQueryRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Gets details about a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_get_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.GetSavedQueryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.GetSavedQueryRequest, dict]): + The request object. Request to get a saved query. + name (:class:`str`): + Required. The name of the saved query and it must be in + the format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = asset_service.GetSavedQueryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_saved_query, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_saved_queries( + self, + request: Union[asset_service.ListSavedQueriesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSavedQueriesAsyncPager: + r"""Lists all saved queries in a parent + project/folder/organization. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_list_saved_queries(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.ListSavedQueriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_saved_queries(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.ListSavedQueriesRequest, dict]): + The request object. Request to list saved queries. + parent (:class:`str`): + Required. The parent + project/folder/organization whose + savedQueries are to be listed. It can + only be using + project/folder/organization number (such + as "folders/12345")", or a project ID + (such as "projects/my-project-id"). + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesAsyncPager: + Response of listing saved queries. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = asset_service.ListSavedQueriesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_saved_queries, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListSavedQueriesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_saved_query( + self, + request: Union[asset_service.UpdateSavedQueryRequest, dict] = None, + *, + saved_query: asset_service.SavedQuery = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Updates a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_update_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.UpdateSavedQueryRequest( + ) + + # Make the request + response = await client.update_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.UpdateSavedQueryRequest, dict]): + The request object. Request to update a saved query. + saved_query (:class:`google.cloud.asset_v1.types.SavedQuery`): + Required. The saved query to update. + + The saved query's ``name`` field is used to identify the + one to update, which has format as below: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + This corresponds to the ``saved_query`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to + update. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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([saved_query, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = asset_service.UpdateSavedQueryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if saved_query is not None: + request.saved_query = saved_query + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_saved_query, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("saved_query.name", request.saved_query.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_saved_query( + self, + request: Union[asset_service.DeleteSavedQueryRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_delete_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.DeleteSavedQueryRequest( + name="name_value", + ) + + # Make the request + await client.delete_saved_query(request=request) + + Args: + request (Union[google.cloud.asset_v1.types.DeleteSavedQueryRequest, dict]): + The request object. Request to delete a saved query. + name (:class:`str`): + Required. The name of the saved query to delete. It must + be in the format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = asset_service.DeleteSavedQueryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_saved_query, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def batch_get_effective_iam_policies( + self, + request: Union[asset_service.BatchGetEffectiveIamPoliciesRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.BatchGetEffectiveIamPoliciesResponse: + r"""Gets effective IAM policies for a batch of resources. + + .. code-block:: python + + from google.cloud import asset_v1 + + async def sample_batch_get_effective_iam_policies(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.BatchGetEffectiveIamPoliciesRequest( + scope="scope_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + response = await client.batch_get_effective_iam_policies(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesRequest, dict]): + The request object. A request message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse: + A response message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + + """ + # Create or coerce a protobuf request object. + request = asset_service.BatchGetEffectiveIamPoliciesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_get_effective_iam_policies, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("scope", request.scope),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/asset_v1/services/asset_service/client.py b/google/cloud/asset_v1/services/asset_service/client.py index 88fe43bb..b2b9a38a 100644 --- a/google/cloud/asset_v1/services/asset_service/client.py +++ b/google/cloud/asset_v1/services/asset_service/client.py @@ -39,6 +39,8 @@ from google.cloud.asset_v1.services.asset_service import pagers from google.cloud.asset_v1.types import asset_service from google.cloud.asset_v1.types import assets +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 from .transports.base import AssetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import AssetServiceGrpcTransport @@ -243,6 +245,25 @@ def parse_inventory_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def saved_query_path( + project: str, + saved_query: str, + ) -> str: + """Returns a fully-qualified saved_query string.""" + return "projects/{project}/savedQueries/{saved_query}".format( + project=project, + saved_query=saved_query, + ) + + @staticmethod + def parse_saved_query_path(path: str) -> Dict[str, str]: + """Parses a saved_query path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/savedQueries/(?P.+?)$", path + ) + return m.groupdict() if m else {} + @staticmethod def service_perimeter_path( access_policy: str, @@ -519,10 +540,10 @@ def export_assets( line represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for BigQuery table destinations, the output - table stores the fields in asset proto as columns. This API + table stores the fields in asset Protobuf as columns. This API implements the - [google.longrunning.Operation][google.longrunning.Operation] API - , which allows you to keep track of the export. We recommend + [google.longrunning.Operation][google.longrunning.Operation] + API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. @@ -647,11 +668,13 @@ def sample_list_assets(): request (Union[google.cloud.asset_v1.types.ListAssetsRequest, dict]): The request object. ListAssets request. parent (str): - Required. Name of the organization or project the assets - belong to. Format: "organizations/[organization-number]" - (such as "organizations/123"), "projects/[project-id]" - (such as "projects/my-project-id"), or - "projects/[project-number]" (such as "projects/12345"). + Required. Name of the organization, folder, or project + the assets belong to. Format: + "organizations/[organization-number]" (such as + "organizations/123"), "projects/[project-id]" (such as + "projects/my-project-id"), "projects/[project-number]" + (such as "projects/12345"), or "folders/[folder-number]" + (such as "folders/12345"). This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -1564,10 +1587,10 @@ def sample_search_all_iam_policies(): search all the IAM policies within the specified ``scope``. Note that the query string is compared against each Cloud IAM policy binding, including its - members, roles, and Cloud IAM conditions. The returned - Cloud IAM policies will only contain the bindings that - match your query. To learn more about the IAM policy - structure, see `IAM policy + principals, roles, and Cloud IAM conditions. The + returned Cloud IAM policies will only contain the + bindings that match your query. To learn more about the + IAM policy structure, see `IAM policy doc `__. Examples: @@ -1609,7 +1632,7 @@ def sample_search_all_iam_policies(): - ``roles:roles/compute.admin`` to find IAM policy bindings that specify the Compute Admin role. - ``memberTypes:user`` to find IAM policy bindings that - contain the "user" member type. + contain the principal type "user". This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this @@ -1727,7 +1750,7 @@ def sample_analyze_iam_policy(): Returns: google.cloud.asset_v1.types.AnalyzeIamPolicyResponse: A response message for - [AssetService.AnalyzeIamPolicy][google.cloud.asset.v1.AssetService.AnalyzeIamPolicy]. + [AssetService.AnalyzeIamPolicy][google.cloud.asset.v1.AssetService.AnalyzeIamPolicy]. """ # Create or coerce a protobuf request object. @@ -1826,10 +1849,8 @@ def sample_analyze_iam_policy_longrunning(): google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be - :class:`google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningResponse` - A response message for - [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning]. + The result type for the operation will be :class:`google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningResponse` A response message for + [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning]. """ # Create or coerce a protobuf request object. @@ -1954,6 +1975,619 @@ def sample_analyze_move(): # Done; return the response. return response + def create_saved_query( + self, + request: Union[asset_service.CreateSavedQueryRequest, dict] = None, + *, + parent: str = None, + saved_query: asset_service.SavedQuery = None, + saved_query_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Creates a saved query in a parent + project/folder/organization. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_create_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.CreateSavedQueryRequest( + parent="parent_value", + saved_query_id="saved_query_id_value", + ) + + # Make the request + response = client.create_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.CreateSavedQueryRequest, dict]): + The request object. Request to create a saved query. + parent (str): + Required. The name of the project/folder/organization + where this saved_query should be created in. It can only + be an organization number (such as "organizations/123"), + a folder number (such as "folders/123"), a project ID + (such as "projects/my-project-id")", or a project number + (such as "projects/12345"). + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + saved_query (google.cloud.asset_v1.types.SavedQuery): + Required. The saved_query details. The ``name`` field + must be empty as it will be generated based on the + parent and saved_query_id. + + This corresponds to the ``saved_query`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + saved_query_id (str): + Required. The ID to use for the saved query, which must + be unique in the specified parent. It will become the + final component of the saved query's resource name. + + This value should be 4-63 characters, and valid + characters are /[a-z][0-9]-/. + + Notice that this field is required in the saved query + creation, and the ``name`` field of the ``saved_query`` + will be ignored. + + This corresponds to the ``saved_query_id`` 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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, saved_query, saved_query_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.CreateSavedQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.CreateSavedQueryRequest): + request = asset_service.CreateSavedQueryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if saved_query is not None: + request.saved_query = saved_query + if saved_query_id is not None: + request.saved_query_id = saved_query_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_saved_query] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_saved_query( + self, + request: Union[asset_service.GetSavedQueryRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Gets details about a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_get_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.GetSavedQueryRequest( + name="name_value", + ) + + # Make the request + response = client.get_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.GetSavedQueryRequest, dict]): + The request object. Request to get a saved query. + name (str): + Required. The name of the saved query and it must be in + the format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.GetSavedQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.GetSavedQueryRequest): + request = asset_service.GetSavedQueryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_saved_query] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_saved_queries( + self, + request: Union[asset_service.ListSavedQueriesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSavedQueriesPager: + r"""Lists all saved queries in a parent + project/folder/organization. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_list_saved_queries(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.ListSavedQueriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_saved_queries(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.ListSavedQueriesRequest, dict]): + The request object. Request to list saved queries. + parent (str): + Required. The parent + project/folder/organization whose + savedQueries are to be listed. It can + only be using + project/folder/organization number (such + as "folders/12345")", or a project ID + (such as "projects/my-project-id"). + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesPager: + Response of listing saved queries. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.ListSavedQueriesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.ListSavedQueriesRequest): + request = asset_service.ListSavedQueriesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_saved_queries] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListSavedQueriesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_saved_query( + self, + request: Union[asset_service.UpdateSavedQueryRequest, dict] = None, + *, + saved_query: asset_service.SavedQuery = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.SavedQuery: + r"""Updates a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_update_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.UpdateSavedQueryRequest( + ) + + # Make the request + response = client.update_saved_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.UpdateSavedQueryRequest, dict]): + The request object. Request to update a saved query. + saved_query (google.cloud.asset_v1.types.SavedQuery): + Required. The saved query to update. + + The saved query's ``name`` field is used to identify the + one to update, which has format as below: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + This corresponds to the ``saved_query`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to + update. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.SavedQuery: + A saved query which can be shared + with others or used later. + + """ + # Create or coerce a protobuf request object. + # 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([saved_query, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.UpdateSavedQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.UpdateSavedQueryRequest): + request = asset_service.UpdateSavedQueryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if saved_query is not None: + request.saved_query = saved_query + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_saved_query] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("saved_query.name", request.saved_query.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_saved_query( + self, + request: Union[asset_service.DeleteSavedQueryRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a saved query. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_delete_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.DeleteSavedQueryRequest( + name="name_value", + ) + + # Make the request + client.delete_saved_query(request=request) + + Args: + request (Union[google.cloud.asset_v1.types.DeleteSavedQueryRequest, dict]): + The request object. Request to delete a saved query. + name (str): + Required. The name of the saved query to delete. It must + be in the format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # 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: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.DeleteSavedQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.DeleteSavedQueryRequest): + request = asset_service.DeleteSavedQueryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_saved_query] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def batch_get_effective_iam_policies( + self, + request: Union[asset_service.BatchGetEffectiveIamPoliciesRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> asset_service.BatchGetEffectiveIamPoliciesResponse: + r"""Gets effective IAM policies for a batch of resources. + + .. code-block:: python + + from google.cloud import asset_v1 + + def sample_batch_get_effective_iam_policies(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.BatchGetEffectiveIamPoliciesRequest( + scope="scope_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + response = client.batch_get_effective_iam_policies(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesRequest, dict]): + The request object. A request message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse: + A response message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a asset_service.BatchGetEffectiveIamPoliciesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, asset_service.BatchGetEffectiveIamPoliciesRequest): + request = asset_service.BatchGetEffectiveIamPoliciesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_get_effective_iam_policies + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("scope", request.scope),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self): return self diff --git a/google/cloud/asset_v1/services/asset_service/pagers.py b/google/cloud/asset_v1/services/asset_service/pagers.py index 7b035da0..0299f36f 100644 --- a/google/cloud/asset_v1/services/asset_service/pagers.py +++ b/google/cloud/asset_v1/services/asset_service/pagers.py @@ -410,3 +410,131 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListSavedQueriesPager: + """A pager for iterating through ``list_saved_queries`` requests. + + This class thinly wraps an initial + :class:`google.cloud.asset_v1.types.ListSavedQueriesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``saved_queries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSavedQueries`` requests and continue to iterate + through the ``saved_queries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.asset_v1.types.ListSavedQueriesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., asset_service.ListSavedQueriesResponse], + request: asset_service.ListSavedQueriesRequest, + response: asset_service.ListSavedQueriesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.asset_v1.types.ListSavedQueriesRequest): + The initial request object. + response (google.cloud.asset_v1.types.ListSavedQueriesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = asset_service.ListSavedQueriesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[asset_service.ListSavedQueriesResponse]: + 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) -> Iterator[asset_service.SavedQuery]: + for page in self.pages: + yield from page.saved_queries + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListSavedQueriesAsyncPager: + """A pager for iterating through ``list_saved_queries`` requests. + + This class thinly wraps an initial + :class:`google.cloud.asset_v1.types.ListSavedQueriesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``saved_queries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSavedQueries`` requests and continue to iterate + through the ``saved_queries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.asset_v1.types.ListSavedQueriesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[asset_service.ListSavedQueriesResponse]], + request: asset_service.ListSavedQueriesRequest, + response: asset_service.ListSavedQueriesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.asset_v1.types.ListSavedQueriesRequest): + The initial request object. + response (google.cloud.asset_v1.types.ListSavedQueriesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = asset_service.ListSavedQueriesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[asset_service.ListSavedQueriesResponse]: + 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) -> AsyncIterator[asset_service.SavedQuery]: + async def async_generator(): + async for page in self.pages: + for response in page.saved_queries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/asset_v1/services/asset_service/transports/base.py b/google/cloud/asset_v1/services/asset_service/transports/base.py index e8b5a94f..5e8a5a49 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/base.py +++ b/google/cloud/asset_v1/services/asset_service/transports/base.py @@ -266,6 +266,36 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_saved_query: gapic_v1.method.wrap_method( + self.create_saved_query, + default_timeout=None, + client_info=client_info, + ), + self.get_saved_query: gapic_v1.method.wrap_method( + self.get_saved_query, + default_timeout=None, + client_info=client_info, + ), + self.list_saved_queries: gapic_v1.method.wrap_method( + self.list_saved_queries, + default_timeout=None, + client_info=client_info, + ), + self.update_saved_query: gapic_v1.method.wrap_method( + self.update_saved_query, + default_timeout=None, + client_info=client_info, + ), + self.delete_saved_query: gapic_v1.method.wrap_method( + self.delete_saved_query, + default_timeout=None, + client_info=client_info, + ), + self.batch_get_effective_iam_policies: gapic_v1.method.wrap_method( + self.batch_get_effective_iam_policies, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -419,6 +449,66 @@ def analyze_move( ]: raise NotImplementedError() + @property + def create_saved_query( + self, + ) -> Callable[ + [asset_service.CreateSavedQueryRequest], + Union[asset_service.SavedQuery, Awaitable[asset_service.SavedQuery]], + ]: + raise NotImplementedError() + + @property + def get_saved_query( + self, + ) -> Callable[ + [asset_service.GetSavedQueryRequest], + Union[asset_service.SavedQuery, Awaitable[asset_service.SavedQuery]], + ]: + raise NotImplementedError() + + @property + def list_saved_queries( + self, + ) -> Callable[ + [asset_service.ListSavedQueriesRequest], + Union[ + asset_service.ListSavedQueriesResponse, + Awaitable[asset_service.ListSavedQueriesResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_saved_query( + self, + ) -> Callable[ + [asset_service.UpdateSavedQueryRequest], + Union[asset_service.SavedQuery, Awaitable[asset_service.SavedQuery]], + ]: + raise NotImplementedError() + + @property + def delete_saved_query( + self, + ) -> Callable[ + [asset_service.DeleteSavedQueryRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def batch_get_effective_iam_policies( + self, + ) -> Callable[ + [asset_service.BatchGetEffectiveIamPoliciesRequest], + Union[ + asset_service.BatchGetEffectiveIamPoliciesResponse, + Awaitable[asset_service.BatchGetEffectiveIamPoliciesResponse], + ], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/asset_v1/services/asset_service/transports/grpc.py b/google/cloud/asset_v1/services/asset_service/transports/grpc.py index 129ff098..0cf6d0ff 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/grpc.py +++ b/google/cloud/asset_v1/services/asset_service/transports/grpc.py @@ -257,10 +257,10 @@ def export_assets( line represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for BigQuery table destinations, the output - table stores the fields in asset proto as columns. This API + table stores the fields in asset Protobuf as columns. This API implements the - [google.longrunning.Operation][google.longrunning.Operation] API - , which allows you to keep track of the export. We recommend + [google.longrunning.Operation][google.longrunning.Operation] + API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. @@ -644,6 +644,172 @@ def analyze_move( ) return self._stubs["analyze_move"] + @property + def create_saved_query( + self, + ) -> Callable[[asset_service.CreateSavedQueryRequest], asset_service.SavedQuery]: + r"""Return a callable for the create saved query method over gRPC. + + Creates a saved query in a parent + project/folder/organization. + + Returns: + Callable[[~.CreateSavedQueryRequest], + ~.SavedQuery]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_saved_query" not in self._stubs: + self._stubs["create_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/CreateSavedQuery", + request_serializer=asset_service.CreateSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["create_saved_query"] + + @property + def get_saved_query( + self, + ) -> Callable[[asset_service.GetSavedQueryRequest], asset_service.SavedQuery]: + r"""Return a callable for the get saved query method over gRPC. + + Gets details about a saved query. + + Returns: + Callable[[~.GetSavedQueryRequest], + ~.SavedQuery]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_saved_query" not in self._stubs: + self._stubs["get_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/GetSavedQuery", + request_serializer=asset_service.GetSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["get_saved_query"] + + @property + def list_saved_queries( + self, + ) -> Callable[ + [asset_service.ListSavedQueriesRequest], asset_service.ListSavedQueriesResponse + ]: + r"""Return a callable for the list saved queries method over gRPC. + + Lists all saved queries in a parent + project/folder/organization. + + Returns: + Callable[[~.ListSavedQueriesRequest], + ~.ListSavedQueriesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_saved_queries" not in self._stubs: + self._stubs["list_saved_queries"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/ListSavedQueries", + request_serializer=asset_service.ListSavedQueriesRequest.serialize, + response_deserializer=asset_service.ListSavedQueriesResponse.deserialize, + ) + return self._stubs["list_saved_queries"] + + @property + def update_saved_query( + self, + ) -> Callable[[asset_service.UpdateSavedQueryRequest], asset_service.SavedQuery]: + r"""Return a callable for the update saved query method over gRPC. + + Updates a saved query. + + Returns: + Callable[[~.UpdateSavedQueryRequest], + ~.SavedQuery]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_saved_query" not in self._stubs: + self._stubs["update_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/UpdateSavedQuery", + request_serializer=asset_service.UpdateSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["update_saved_query"] + + @property + def delete_saved_query( + self, + ) -> Callable[[asset_service.DeleteSavedQueryRequest], empty_pb2.Empty]: + r"""Return a callable for the delete saved query method over gRPC. + + Deletes a saved query. + + Returns: + Callable[[~.DeleteSavedQueryRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_saved_query" not in self._stubs: + self._stubs["delete_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/DeleteSavedQuery", + request_serializer=asset_service.DeleteSavedQueryRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_saved_query"] + + @property + def batch_get_effective_iam_policies( + self, + ) -> Callable[ + [asset_service.BatchGetEffectiveIamPoliciesRequest], + asset_service.BatchGetEffectiveIamPoliciesResponse, + ]: + r"""Return a callable for the batch get effective iam + policies method over gRPC. + + Gets effective IAM policies for a batch of resources. + + Returns: + Callable[[~.BatchGetEffectiveIamPoliciesRequest], + ~.BatchGetEffectiveIamPoliciesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_get_effective_iam_policies" not in self._stubs: + self._stubs[ + "batch_get_effective_iam_policies" + ] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/BatchGetEffectiveIamPolicies", + request_serializer=asset_service.BatchGetEffectiveIamPoliciesRequest.serialize, + response_deserializer=asset_service.BatchGetEffectiveIamPoliciesResponse.deserialize, + ) + return self._stubs["batch_get_effective_iam_policies"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py b/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py index b05e4bd1..8839bd59 100644 --- a/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py +++ b/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py @@ -264,10 +264,10 @@ def export_assets( line represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for BigQuery table destinations, the output - table stores the fields in asset proto as columns. This API + table stores the fields in asset Protobuf as columns. This API implements the - [google.longrunning.Operation][google.longrunning.Operation] API - , which allows you to keep track of the export. We recommend + [google.longrunning.Operation][google.longrunning.Operation] + API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes. @@ -659,6 +659,179 @@ def analyze_move( ) return self._stubs["analyze_move"] + @property + def create_saved_query( + self, + ) -> Callable[ + [asset_service.CreateSavedQueryRequest], Awaitable[asset_service.SavedQuery] + ]: + r"""Return a callable for the create saved query method over gRPC. + + Creates a saved query in a parent + project/folder/organization. + + Returns: + Callable[[~.CreateSavedQueryRequest], + Awaitable[~.SavedQuery]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_saved_query" not in self._stubs: + self._stubs["create_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/CreateSavedQuery", + request_serializer=asset_service.CreateSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["create_saved_query"] + + @property + def get_saved_query( + self, + ) -> Callable[ + [asset_service.GetSavedQueryRequest], Awaitable[asset_service.SavedQuery] + ]: + r"""Return a callable for the get saved query method over gRPC. + + Gets details about a saved query. + + Returns: + Callable[[~.GetSavedQueryRequest], + Awaitable[~.SavedQuery]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_saved_query" not in self._stubs: + self._stubs["get_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/GetSavedQuery", + request_serializer=asset_service.GetSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["get_saved_query"] + + @property + def list_saved_queries( + self, + ) -> Callable[ + [asset_service.ListSavedQueriesRequest], + Awaitable[asset_service.ListSavedQueriesResponse], + ]: + r"""Return a callable for the list saved queries method over gRPC. + + Lists all saved queries in a parent + project/folder/organization. + + Returns: + Callable[[~.ListSavedQueriesRequest], + Awaitable[~.ListSavedQueriesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_saved_queries" not in self._stubs: + self._stubs["list_saved_queries"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/ListSavedQueries", + request_serializer=asset_service.ListSavedQueriesRequest.serialize, + response_deserializer=asset_service.ListSavedQueriesResponse.deserialize, + ) + return self._stubs["list_saved_queries"] + + @property + def update_saved_query( + self, + ) -> Callable[ + [asset_service.UpdateSavedQueryRequest], Awaitable[asset_service.SavedQuery] + ]: + r"""Return a callable for the update saved query method over gRPC. + + Updates a saved query. + + Returns: + Callable[[~.UpdateSavedQueryRequest], + Awaitable[~.SavedQuery]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_saved_query" not in self._stubs: + self._stubs["update_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/UpdateSavedQuery", + request_serializer=asset_service.UpdateSavedQueryRequest.serialize, + response_deserializer=asset_service.SavedQuery.deserialize, + ) + return self._stubs["update_saved_query"] + + @property + def delete_saved_query( + self, + ) -> Callable[[asset_service.DeleteSavedQueryRequest], Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete saved query method over gRPC. + + Deletes a saved query. + + Returns: + Callable[[~.DeleteSavedQueryRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_saved_query" not in self._stubs: + self._stubs["delete_saved_query"] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/DeleteSavedQuery", + request_serializer=asset_service.DeleteSavedQueryRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_saved_query"] + + @property + def batch_get_effective_iam_policies( + self, + ) -> Callable[ + [asset_service.BatchGetEffectiveIamPoliciesRequest], + Awaitable[asset_service.BatchGetEffectiveIamPoliciesResponse], + ]: + r"""Return a callable for the batch get effective iam + policies method over gRPC. + + Gets effective IAM policies for a batch of resources. + + Returns: + Callable[[~.BatchGetEffectiveIamPoliciesRequest], + Awaitable[~.BatchGetEffectiveIamPoliciesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_get_effective_iam_policies" not in self._stubs: + self._stubs[ + "batch_get_effective_iam_policies" + ] = self.grpc_channel.unary_unary( + "/google.cloud.asset.v1.AssetService/BatchGetEffectiveIamPolicies", + request_serializer=asset_service.BatchGetEffectiveIamPoliciesRequest.serialize, + response_deserializer=asset_service.BatchGetEffectiveIamPoliciesResponse.deserialize, + ) + return self._stubs["batch_get_effective_iam_policies"] + def close(self): return self.grpc_channel.close() diff --git a/google/cloud/asset_v1/types/__init__.py b/google/cloud/asset_v1/types/__init__.py index a9710b67..e93d4261 100644 --- a/google/cloud/asset_v1/types/__init__.py +++ b/google/cloud/asset_v1/types/__init__.py @@ -23,9 +23,13 @@ AnalyzeMoveResponse, BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse, + BatchGetEffectiveIamPoliciesRequest, + BatchGetEffectiveIamPoliciesResponse, BigQueryDestination, CreateFeedRequest, + CreateSavedQueryRequest, DeleteFeedRequest, + DeleteSavedQueryRequest, ExportAssetsRequest, ExportAssetsResponse, Feed, @@ -33,12 +37,15 @@ GcsDestination, GcsOutputResult, GetFeedRequest, + GetSavedQueryRequest, IamPolicyAnalysisOutputConfig, IamPolicyAnalysisQuery, ListAssetsRequest, ListAssetsResponse, ListFeedsRequest, ListFeedsResponse, + ListSavedQueriesRequest, + ListSavedQueriesResponse, MoveAnalysis, MoveAnalysisResult, MoveImpact, @@ -46,11 +53,13 @@ OutputResult, PartitionSpec, PubsubDestination, + SavedQuery, SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, SearchAllResourcesRequest, SearchAllResourcesResponse, UpdateFeedRequest, + UpdateSavedQueryRequest, ContentType, ) from .assets import ( @@ -82,9 +91,13 @@ "AnalyzeMoveResponse", "BatchGetAssetsHistoryRequest", "BatchGetAssetsHistoryResponse", + "BatchGetEffectiveIamPoliciesRequest", + "BatchGetEffectiveIamPoliciesResponse", "BigQueryDestination", "CreateFeedRequest", + "CreateSavedQueryRequest", "DeleteFeedRequest", + "DeleteSavedQueryRequest", "ExportAssetsRequest", "ExportAssetsResponse", "Feed", @@ -92,12 +105,15 @@ "GcsDestination", "GcsOutputResult", "GetFeedRequest", + "GetSavedQueryRequest", "IamPolicyAnalysisOutputConfig", "IamPolicyAnalysisQuery", "ListAssetsRequest", "ListAssetsResponse", "ListFeedsRequest", "ListFeedsResponse", + "ListSavedQueriesRequest", + "ListSavedQueriesResponse", "MoveAnalysis", "MoveAnalysisResult", "MoveImpact", @@ -105,11 +121,13 @@ "OutputResult", "PartitionSpec", "PubsubDestination", + "SavedQuery", "SearchAllIamPoliciesRequest", "SearchAllIamPoliciesResponse", "SearchAllResourcesRequest", "SearchAllResourcesResponse", "UpdateFeedRequest", + "UpdateSavedQueryRequest", "ContentType", "Asset", "AttachedResource", diff --git a/google/cloud/asset_v1/types/asset_service.py b/google/cloud/asset_v1/types/asset_service.py index f96d53c8..d05c5b05 100644 --- a/google/cloud/asset_v1/types/asset_service.py +++ b/google/cloud/asset_v1/types/asset_service.py @@ -16,6 +16,7 @@ import proto # type: ignore from google.cloud.asset_v1.types import assets as gca_assets +from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -59,11 +60,20 @@ "IamPolicyAnalysisOutputConfig", "AnalyzeIamPolicyLongrunningRequest", "AnalyzeIamPolicyLongrunningResponse", + "SavedQuery", + "CreateSavedQueryRequest", + "GetSavedQueryRequest", + "ListSavedQueriesRequest", + "ListSavedQueriesResponse", + "UpdateSavedQueryRequest", + "DeleteSavedQueryRequest", "AnalyzeMoveRequest", "AnalyzeMoveResponse", "MoveAnalysis", "MoveAnalysisResult", "MoveImpact", + "BatchGetEffectiveIamPoliciesRequest", + "BatchGetEffectiveIamPoliciesResponse", }, ) @@ -237,11 +247,13 @@ class ListAssetsRequest(proto.Message): Attributes: parent (str): - Required. Name of the organization or project the assets - belong to. Format: "organizations/[organization-number]" - (such as "organizations/123"), "projects/[project-id]" (such - as "projects/my-project-id"), or "projects/[project-number]" - (such as "projects/12345"). + Required. Name of the organization, folder, or project the + assets belong to. Format: + "organizations/[organization-number]" (such as + "organizations/123"), "projects/[project-id]" (such as + "projects/my-project-id"), "projects/[project-number]" (such + as "projects/12345"), or "folders/[folder-number]" (such as + "folders/12345"). read_time (google.protobuf.timestamp_pb2.Timestamp): Timestamp to take an asset snapshot. This can only be set to a timestamp between the current @@ -614,8 +626,8 @@ class OutputConfig(proto.Message): This field is a member of `oneof`_ ``destination``. bigquery_destination (google.cloud.asset_v1.types.BigQueryDestination): Destination on BigQuery. The output table - stores the fields in asset proto as columns in - BigQuery. + stores the fields in asset Protobuf as columns + in BigQuery. This field is a member of `oneof`_ ``destination``. """ @@ -728,6 +740,12 @@ class BigQueryDestination(proto.Message): "projects/projectId/datasets/datasetId", to which the snapshot result should be exported. If this dataset does not exist, the export call returns an INVALID_ARGUMENT error. + Setting the ``contentType`` for ``exportAssets`` determines + the + `schema `__ + of the BigQuery table. Setting + ``separateTablesPerAssetType`` to ``TRUE`` also influences + the schema. table (str): Required. The BigQuery table to which the snapshot result should be written. If this table @@ -908,9 +926,9 @@ class Feed(proto.Message): asset_names or asset_types are exported to the feed. Example: ``//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1``. - See `Resource - Names `__ - for more info. + For a list of the full names for supported asset types, see + `Resource name + format `__. asset_types (Sequence[str]): A list of types of the assets to receive updates. You must specify either or both of asset_names and asset_types. Only @@ -918,9 +936,9 @@ class Feed(proto.Message): are exported to the feed. Example: ``"compute.googleapis.com/Disk"`` - See `this - topic `__ - for a list of all supported asset types. + For a list of all supported asset types, see `Supported + asset + types `__. content_type (google.cloud.asset_v1.types.ContentType): Asset content type. If not specified, no content but the asset name and type will be @@ -1132,6 +1150,9 @@ class SearchAllResourcesRequest(proto.Message): - displayName - description - location + - tagKeys + - tagValues + - tagValueIds - labels - networkTags - kmsKey @@ -1233,10 +1254,10 @@ class SearchAllIamPoliciesRequest(proto.Message): for more information. If not specified or empty, it will search all the IAM policies within the specified ``scope``. Note that the query string is compared against each Cloud - IAM policy binding, including its members, roles, and Cloud - IAM conditions. The returned Cloud IAM policies will only - contain the bindings that match your query. To learn more - about the IAM policy structure, see `IAM policy + IAM policy binding, including its principals, roles, and + Cloud IAM conditions. The returned Cloud IAM policies will + only contain the bindings that match your query. To learn + more about the IAM policy structure, see `IAM policy doc `__. Examples: @@ -1273,7 +1294,7 @@ class SearchAllIamPoliciesRequest(proto.Message): - ``roles:roles/compute.admin`` to find IAM policy bindings that specify the Compute Admin role. - ``memberTypes:user`` to find IAM policy bindings that - contain the "user" member type. + contain the principal type "user". page_size (int): Optional. The page size for search result pagination. Page size is capped at 500 even if a larger value is given. If @@ -1379,7 +1400,7 @@ def raw_page(self): class IamPolicyAnalysisQuery(proto.Message): - r"""## IAM policy analysis query message. + r"""IAM policy analysis query message. Attributes: scope (str): @@ -1437,8 +1458,8 @@ class IdentitySelector(proto.Message): Attributes: identity (str): - Required. The identity appear in the form of members in `IAM - policy + Required. The identity appear in the form of principals in + `IAM policy binding `__. The examples of supported forms are: @@ -1492,6 +1513,9 @@ class Options(proto.Message): is specified, the identity in the result will be determined by the selector, and this flag is not allowed to set. + If true, the default max expansion per group is 1000 for + AssetService.AnalyzeIamPolicy][]. + Default is false. expand_roles (bool): Optional. If true, the access section of result will expand @@ -1530,17 +1554,20 @@ class Options(proto.Message): results will include all users who have permission P on that project or any lower resource. + If true, the default max expansion per resource is 1000 for + AssetService.AnalyzeIamPolicy][] and 100000 for + AssetService.AnalyzeIamPolicyLongrunning][]. + Default is false. output_resource_edges (bool): - Optional. If true, the result will output - resource edges, starting from the policy - attached resource, to any expanded resources. - Default is false. + Optional. If true, the result will output the + relevant parent/child relationships between + resources. Default is false. output_group_edges (bool): - Optional. If true, the result will output - group identity edges, starting from the - binding's group members, to any expanded - identities. Default is false. + Optional. If true, the result will output the + relevant membership relationships between groups + and other groups, and between groups and + principals. Default is false. analyze_service_account_impersonation (bool): Optional. If true, the response will include access analysis from identities to resources via service account @@ -1568,6 +1595,16 @@ class Options(proto.Message): those advanced analysis results will be included in [AnalyzeIamPolicyResponse.service_account_impersonation_analysis][google.cloud.asset.v1.AnalyzeIamPolicyResponse.service_account_impersonation_analysis]. + Only the following permissions are considered in this + analysis: + + - ``iam.serviceAccounts.actAs`` + - ``iam.serviceAccounts.signBlob`` + - ``iam.serviceAccounts.signJwt`` + - ``iam.serviceAccounts.getAccessToken`` + - ``iam.serviceAccounts.getOpenIdToken`` + - ``iam.serviceAccounts.implicitDelegation`` + Default is false. """ @@ -1656,6 +1693,25 @@ class AnalyzeIamPolicyRequest(proto.Message): Attributes: analysis_query (google.cloud.asset_v1.types.IamPolicyAnalysisQuery): Required. The request query. + saved_analysis_query (str): + Optional. The name of a saved query, which must be in the + format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + If both ``analysis_query`` and ``saved_analysis_query`` are + provided, they will be merged together with the + ``saved_analysis_query`` as base and the ``analysis_query`` + as overrides. For more details of the merge behavior, please + refer to the + `MergeFrom `__ + page. + + Note that you cannot override primitive fields with default + value, such as 0 or empty string, etc., because we use + proto3, which doesn't support field presence yet. execution_timeout (google.protobuf.duration_pb2.Duration): Optional. Amount of time executable has to complete. See JSON representation of @@ -1676,6 +1732,10 @@ class AnalyzeIamPolicyRequest(proto.Message): number=1, message="IamPolicyAnalysisQuery", ) + saved_analysis_query = proto.Field( + proto.STRING, + number=3, + ) execution_timeout = proto.Field( proto.MESSAGE, number=2, @@ -1897,6 +1957,25 @@ class AnalyzeIamPolicyLongrunningRequest(proto.Message): Attributes: analysis_query (google.cloud.asset_v1.types.IamPolicyAnalysisQuery): Required. The request query. + saved_analysis_query (str): + Optional. The name of a saved query, which must be in the + format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + + If both ``analysis_query`` and ``saved_analysis_query`` are + provided, they will be merged together with the + ``saved_analysis_query`` as base and the ``analysis_query`` + as overrides. For more details of the merge behavior, please + refer to the + `MergeFrom `__ + doc. + + Note that you cannot override primitive fields with default + value, such as 0 or empty string, etc., because we use + proto3, which doesn't support field presence yet. output_config (google.cloud.asset_v1.types.IamPolicyAnalysisOutputConfig): Required. Output configuration indicating where the results will be output to. @@ -1907,6 +1986,10 @@ class AnalyzeIamPolicyLongrunningRequest(proto.Message): number=1, message="IamPolicyAnalysisQuery", ) + saved_analysis_query = proto.Field( + proto.STRING, + number=3, + ) output_config = proto.Field( proto.MESSAGE, number=2, @@ -1921,6 +2004,294 @@ class AnalyzeIamPolicyLongrunningResponse(proto.Message): """ +class SavedQuery(proto.Message): + r"""A saved query which can be shared with others or used later. + + Attributes: + name (str): + The resource name of the saved query. The format must be: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + description (str): + The description of this saved query. This + value should be fewer than 255 characters. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The create time of this saved + query. + creator (str): + Output only. The account's email address who + has created this saved query. + last_update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last update time of this + saved query. + last_updater (str): + Output only. The account's email address who + has updated this saved query most recently. + labels (Mapping[str, str]): + Labels applied on the resource. + This value should not contain more than 10 + entries. The key and value of each entry must be + non-empty and fewer than 64 characters. + content (google.cloud.asset_v1.types.SavedQuery.QueryContent): + The query content. + """ + + class QueryContent(proto.Message): + r"""The query content. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + iam_policy_analysis_query (google.cloud.asset_v1.types.IamPolicyAnalysisQuery): + An IAM Policy Analysis query, which could be used in the + [AssetService.AnalyzeIamPolicy][google.cloud.asset.v1.AssetService.AnalyzeIamPolicy] + rpc or the + [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning] + rpc. + + This field is a member of `oneof`_ ``query_content``. + """ + + iam_policy_analysis_query = proto.Field( + proto.MESSAGE, + number=1, + oneof="query_content", + message="IamPolicyAnalysisQuery", + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + creator = proto.Field( + proto.STRING, + number=4, + ) + last_update_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + last_updater = proto.Field( + proto.STRING, + number=6, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + content = proto.Field( + proto.MESSAGE, + number=8, + message=QueryContent, + ) + + +class CreateSavedQueryRequest(proto.Message): + r"""Request to create a saved query. + + Attributes: + parent (str): + Required. The name of the project/folder/organization where + this saved_query should be created in. It can only be an + organization number (such as "organizations/123"), a folder + number (such as "folders/123"), a project ID (such as + "projects/my-project-id")", or a project number (such as + "projects/12345"). + saved_query (google.cloud.asset_v1.types.SavedQuery): + Required. The saved_query details. The ``name`` field must + be empty as it will be generated based on the parent and + saved_query_id. + saved_query_id (str): + Required. The ID to use for the saved query, which must be + unique in the specified parent. It will become the final + component of the saved query's resource name. + + This value should be 4-63 characters, and valid characters + are /[a-z][0-9]-/. + + Notice that this field is required in the saved query + creation, and the ``name`` field of the ``saved_query`` will + be ignored. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + saved_query = proto.Field( + proto.MESSAGE, + number=2, + message="SavedQuery", + ) + saved_query_id = proto.Field( + proto.STRING, + number=3, + ) + + +class GetSavedQueryRequest(proto.Message): + r"""Request to get a saved query. + + Attributes: + name (str): + Required. The name of the saved query and it must be in the + format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListSavedQueriesRequest(proto.Message): + r"""Request to list saved queries. + + Attributes: + parent (str): + Required. The parent + project/folder/organization whose savedQueries + are to be listed. It can only be using + project/folder/organization number (such as + "folders/12345")", or a project ID (such as + "projects/my-project-id"). + filter (str): + Optional. The expression to filter resources. The expression + is a list of zero or more restrictions combined via logical + operators ``AND`` and ``OR``. When ``AND`` and ``OR`` are + both used in the expression, parentheses must be + appropriately used to group the combinations. The expression + may also contain regular expressions. + + See https://google.aip.dev/160 for more information on the + grammar. + page_size (int): + Optional. The maximum number of saved queries + to return per page. The service may return fewer + than this value. If unspecified, at most 50 will + be returned. + The maximum value is 1000; values above 1000 + will be coerced to 1000. + page_token (str): + Optional. A page token, received from a previous + ``ListSavedQueries`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListSavedQueries`` must match the call that provided the + page token. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListSavedQueriesResponse(proto.Message): + r"""Response of listing saved queries. + + Attributes: + saved_queries (Sequence[google.cloud.asset_v1.types.SavedQuery]): + A list of savedQueries. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + saved_queries = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="SavedQuery", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateSavedQueryRequest(proto.Message): + r"""Request to update a saved query. + + Attributes: + saved_query (google.cloud.asset_v1.types.SavedQuery): + Required. The saved query to update. + + The saved query's ``name`` field is used to identify the one + to update, which has format as below: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to update. + """ + + saved_query = proto.Field( + proto.MESSAGE, + number=1, + message="SavedQuery", + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteSavedQueryRequest(proto.Message): + r"""Request to delete a saved query. + + Attributes: + name (str): + Required. The name of the saved query to delete. It must be + in the format of: + + - projects/project_number/savedQueries/saved_query_id + - folders/folder_number/savedQueries/saved_query_id + - organizations/organization_number/savedQueries/saved_query_id + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + class AnalyzeMoveRequest(proto.Message): r"""The request message for performing resource move analysis. @@ -2071,4 +2442,132 @@ class MoveImpact(proto.Message): ) +class BatchGetEffectiveIamPoliciesRequest(proto.Message): + r"""A request message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + + Attributes: + scope (str): + Required. Only IAM policies on or below the scope will be + returned. + + This can only be an organization number (such as + "organizations/123"), a folder number (such as + "folders/123"), a project ID (such as + "projects/my-project-id"), or a project number (such as + "projects/12345"). + + To know how to get organization id, visit + `here `__. + + To know how to get folder or project id, visit + `here `__. + names (Sequence[str]): + Required. The names refer to the [full_resource_names] + (https://cloud.google.com/asset-inventory/docs/resource-name-format) + of `searchable asset + types `__. + A maximum of 20 resources' effective policies can be + retrieved in a batch. + """ + + scope = proto.Field( + proto.STRING, + number=1, + ) + names = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class BatchGetEffectiveIamPoliciesResponse(proto.Message): + r"""A response message for + [AssetService.BatchGetEffectiveIamPolicies][google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies]. + + Attributes: + policy_results (Sequence[google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy]): + The effective policies for a batch of resources. Note that + the results order is the same as the order of + [BatchGetEffectiveIamPoliciesRequest.names][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesRequest.names]. + When a resource does not have any effective IAM policies, + its corresponding policy_result will contain empty + [EffectiveIamPolicy.policies][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.policies]. + """ + + class EffectiveIamPolicy(proto.Message): + r"""The effective IAM policies on one resource. + + Attributes: + full_resource_name (str): + The [full_resource_name] + (https://cloud.google.com/asset-inventory/docs/resource-name-format) + for which the + [policies][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.policies] + are computed. This is one of the + [BatchGetEffectiveIamPoliciesRequest.names][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesRequest.names] + the caller provides in the request. + policies (Sequence[google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo]): + The effective policies for the + [full_resource_name][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.full_resource_name]. + + These policies include the policy set on the + [full_resource_name][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.full_resource_name] + and those set on its parents and ancestors up to the + [BatchGetEffectiveIamPoliciesRequest.scope][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesRequest.scope]. + Note that these policies are not filtered according to the + resource type of the + [full_resource_name][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.full_resource_name]. + + These policies are hierarchically ordered by + [PolicyInfo.attached_resource][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo.attached_resource] + starting from + [full_resource_name][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.full_resource_name] + itself to its parents and ancestors, such that policies[i]'s + [PolicyInfo.attached_resource][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo.attached_resource] + is the child of policies[i+1]'s + [PolicyInfo.attached_resource][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo.attached_resource], + if policies[i+1] exists. + """ + + class PolicyInfo(proto.Message): + r"""The IAM policy and its attached resource. + + Attributes: + attached_resource (str): + The full resource name the + [policy][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo.policy] + is directly attached to. + policy (google.iam.v1.policy_pb2.Policy): + The IAM policy that's directly attached to the + [attached_resource][google.cloud.asset.v1.BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo.attached_resource]. + """ + + attached_resource = proto.Field( + proto.STRING, + number=1, + ) + policy = proto.Field( + proto.MESSAGE, + number=2, + message=policy_pb2.Policy, + ) + + full_resource_name = proto.Field( + proto.STRING, + number=1, + ) + policies = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="BatchGetEffectiveIamPoliciesResponse.EffectiveIamPolicy.PolicyInfo", + ) + + policy_results = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=EffectiveIamPolicy, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/asset_v1/types/assets.py b/google/cloud/asset_v1/types/assets.py index b39a6ac8..3434b534 100644 --- a/google/cloud/asset_v1/types/assets.py +++ b/google/cloud/asset_v1/types/assets.py @@ -204,9 +204,14 @@ class Asset(proto.Message): topic `__ for more information. related_assets (google.cloud.asset_v1.types.RelatedAssets): + DEPRECATED. This field only presents for the + purpose of backward-compatibility. The server + will never generate responses with this field. The related assets of the asset of one relationship type. One asset only represents one type of relationship. + related_asset (google.cloud.asset_v1.types.RelatedAsset): + One related asset of the current asset. ancestors (Sequence[str]): The ancestry path of an asset in Google Cloud `resource hierarchy `__, @@ -276,6 +281,11 @@ class Asset(proto.Message): number=13, message="RelatedAssets", ) + related_asset = proto.Field( + proto.MESSAGE, + number=15, + message="RelatedAsset", + ) ancestors = proto.RepeatedField( proto.STRING, number=10, @@ -363,7 +373,10 @@ class Resource(proto.Message): class RelatedAssets(proto.Message): - r"""The detailed related assets with the ``relationship_type``. + r"""DEPRECATED. This message only presents for the purpose of + backward-compatibility. The server will never populate this message + in responses. The detailed related assets with the + ``relationship_type``. Attributes: relationship_attributes (google.cloud.asset_v1.types.RelationshipAttributes): @@ -385,7 +398,9 @@ class RelatedAssets(proto.Message): class RelationshipAttributes(proto.Message): - r"""The relationship attributes which include ``type``, + r"""DEPRECATED. This message only presents for the purpose of + backward-compatibility. The server will never populate this message + in responses. The relationship attributes which include ``type``, ``source_resource_type``, ``target_resource_type`` and ``action``. Attributes: @@ -422,8 +437,8 @@ class RelationshipAttributes(proto.Message): class RelatedAsset(proto.Message): - r"""An asset identify in Google Cloud which contains its name, type and - ancestors. An asset can be any resource in the Google Cloud + r"""An asset identifier in Google Cloud which contains its name, type + and ancestors. An asset can be any resource in the Google Cloud `resource hierarchy `__, a resource outside the Google Cloud resource hierarchy (such as @@ -456,6 +471,9 @@ class RelatedAsset(proto.Message): Example: ``["projects/123456789", "folders/5432", "organizations/1234"]`` + relationship_type (str): + The unique identifier of the relationship type. Example: + ``INSTANCE_TO_INSTANCEGROUP`` """ asset = proto.Field( @@ -470,6 +488,10 @@ class RelatedAsset(proto.Message): proto.STRING, number=3, ) + relationship_type = proto.Field( + proto.STRING, + number=4, + ) class ResourceSearchResult(proto.Message): @@ -530,7 +552,7 @@ class ResourceSearchResult(proto.Message): search request. display_name (str): The display name of this resource. This field is available - only when the resource's proto contains it. + only when the resource's Protobuf contains it. To search against the ``display_name``: @@ -539,7 +561,7 @@ class ResourceSearchResult(proto.Message): description (str): One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes. This field is - available only when the resource's proto contains it. + available only when the resource's Protobuf contains it. To search against the ``description``: @@ -549,7 +571,7 @@ class ResourceSearchResult(proto.Message): location (str): Location can be ``global``, regional like ``us-east1``, or zonal like ``us-west1-b``. This field is available only when - the resource's proto contains it. + the resource's Protobuf contains it. To search against the ``location``: @@ -560,7 +582,7 @@ class ResourceSearchResult(proto.Message): grouping GCP resources `__ for more information. This field is available only when the - resource's proto contains it. + resource's Protobuf contains it. To search against the ``labels``: @@ -579,7 +601,7 @@ class ResourceSearchResult(proto.Message): resources. See `Labelling GCP resources `__ for more information. This field is available only when the - resource's proto contains it. + resource's Protobuf contains it. To search against the ``network_tags``: @@ -587,11 +609,11 @@ class ResourceSearchResult(proto.Message): - use a free text query. Example: ``internal`` kms_key (str): The Cloud KMS - `CryptoKey `__ + `CryptoKey `__ name or - `CryptoKeyVersion `__ - name. This field is available only when the resource's proto - contains it. + `CryptoKeyVersion `__ + name. This field is available only when the resource's + Protobuf contains it. To search against the ``kms_key``: @@ -601,7 +623,7 @@ class ResourceSearchResult(proto.Message): The create timestamp of this resource, at which the resource was created. The granularity is in seconds. Timestamp.nanos will always be 0. This field is available only when the - resource's proto contains it. + resource's Protobuf contains it. To search against ``create_time``: @@ -617,7 +639,7 @@ class ResourceSearchResult(proto.Message): The last update timestamp of this resource, at which the resource was last modified or deleted. The granularity is in seconds. Timestamp.nanos will always be 0. This field is - available only when the resource's proto contains it. + available only when the resource's Protobuf contains it. To search against ``update_time``: @@ -633,7 +655,7 @@ class ResourceSearchResult(proto.Message): The state of this resource. Different resources types have different state definitions that are mapped from various fields of different resource types. This field is available - only when the resource's proto contains it. + only when the resource's Protobuf contains it. Example: If the resource is an instance provided by Compute Engine, its state will include PROVISIONING, STAGING, @@ -705,6 +727,47 @@ class ResourceSearchResult(proto.Message): ``DISK_TO_INSTANCE``, ``DISK_TO_NETWORK``, ``INSTANCE_TO_INSTANCEGROUP``. See `supported relationship types `__. + tag_keys (Sequence[str]): + TagKey namespaced names, in the format of + {ORG_ID}/{TAG_KEY_SHORT_NAME}. To search against the + ``tagKeys``: + + - use a field query. Example: + + - ``tagKeys:"123456789/env*"`` + - ``tagKeys="123456789/env"`` + - ``tagKeys:"env"`` + + - use a free text query. Example: + + - ``env`` + tag_values (Sequence[str]): + TagValue namespaced names, in the format of + {ORG_ID}/{TAG_KEY_SHORT_NAME}/{TAG_VALUE_SHORT_NAME}. To + search against the ``tagValues``: + + - use a field query. Example: + + - ``tagValues:"env"`` + - ``tagValues:"env/prod"`` + - ``tagValues:"123456789/env/prod*"`` + - ``tagValues="123456789/env/prod"`` + + - use a free text query. Example: + + - ``prod`` + tag_value_ids (Sequence[str]): + TagValue IDs, in the format of tagValues/{TAG_VALUE_ID}. To + search against the ``tagValueIds``: + + - use a field query. Example: + + - ``tagValueIds:"456"`` + - ``tagValueIds="tagValues/456"`` + + - use a free text query. Example: + + - ``456`` parent_asset_type (str): The type of this resource's immediate parent, if there is one. @@ -801,6 +864,18 @@ class ResourceSearchResult(proto.Message): number=21, message="RelatedResources", ) + tag_keys = proto.RepeatedField( + proto.STRING, + number=23, + ) + tag_values = proto.RepeatedField( + proto.STRING, + number=25, + ) + tag_value_ids = proto.RepeatedField( + proto.STRING, + number=26, + ) parent_asset_type = proto.Field( proto.STRING, number=103, diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py new file mode 100644 index 00000000..1b668f58 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py @@ -0,0 +1,46 @@ +# -*- 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 BatchGetEffectiveIamPolicies +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_async] +from google.cloud import asset_v1 + + +async def sample_batch_get_effective_iam_policies(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.BatchGetEffectiveIamPoliciesRequest( + scope="scope_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + response = await client.batch_get_effective_iam_policies(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py new file mode 100644 index 00000000..82bfbd0d --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py @@ -0,0 +1,46 @@ +# -*- 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 BatchGetEffectiveIamPolicies +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_sync] +from google.cloud import asset_v1 + + +def sample_batch_get_effective_iam_policies(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.BatchGetEffectiveIamPoliciesRequest( + scope="scope_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + response = client.batch_get_effective_iam_policies(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_sync] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_async.py new file mode 100644 index 00000000..d5edb69c --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_async.py @@ -0,0 +1,46 @@ +# -*- 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 CreateSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_CreateSavedQuery_async] +from google.cloud import asset_v1 + + +async def sample_create_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.CreateSavedQueryRequest( + parent="parent_value", + saved_query_id="saved_query_id_value", + ) + + # Make the request + response = await client.create_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_CreateSavedQuery_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_sync.py new file mode 100644 index 00000000..1601b6ed --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_create_saved_query_sync.py @@ -0,0 +1,46 @@ +# -*- 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 CreateSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_CreateSavedQuery_sync] +from google.cloud import asset_v1 + + +def sample_create_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.CreateSavedQueryRequest( + parent="parent_value", + saved_query_id="saved_query_id_value", + ) + + # Make the request + response = client.create_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_CreateSavedQuery_sync] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_async.py new file mode 100644 index 00000000..e0013fe8 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_async.py @@ -0,0 +1,43 @@ +# -*- 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 DeleteSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_DeleteSavedQuery_async] +from google.cloud import asset_v1 + + +async def sample_delete_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.DeleteSavedQueryRequest( + name="name_value", + ) + + # Make the request + await client.delete_saved_query(request=request) + + +# [END cloudasset_v1_generated_AssetService_DeleteSavedQuery_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_sync.py new file mode 100644 index 00000000..9d6edc66 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_delete_saved_query_sync.py @@ -0,0 +1,43 @@ +# -*- 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 DeleteSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_DeleteSavedQuery_sync] +from google.cloud import asset_v1 + + +def sample_delete_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.DeleteSavedQueryRequest( + name="name_value", + ) + + # Make the request + client.delete_saved_query(request=request) + + +# [END cloudasset_v1_generated_AssetService_DeleteSavedQuery_sync] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_async.py new file mode 100644 index 00000000..7c606c81 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_async.py @@ -0,0 +1,45 @@ +# -*- 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 GetSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_GetSavedQuery_async] +from google.cloud import asset_v1 + + +async def sample_get_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.GetSavedQueryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_GetSavedQuery_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_sync.py new file mode 100644 index 00000000..ed758e8b --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_get_saved_query_sync.py @@ -0,0 +1,45 @@ +# -*- 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 GetSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_GetSavedQuery_sync] +from google.cloud import asset_v1 + + +def sample_get_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.GetSavedQueryRequest( + name="name_value", + ) + + # Make the request + response = client.get_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_GetSavedQuery_sync] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_async.py new file mode 100644 index 00000000..7bf406c8 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_async.py @@ -0,0 +1,46 @@ +# -*- 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 ListSavedQueries +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_ListSavedQueries_async] +from google.cloud import asset_v1 + + +async def sample_list_saved_queries(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.ListSavedQueriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_saved_queries(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudasset_v1_generated_AssetService_ListSavedQueries_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_sync.py new file mode 100644 index 00000000..cb0be147 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_list_saved_queries_sync.py @@ -0,0 +1,46 @@ +# -*- 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 ListSavedQueries +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_ListSavedQueries_sync] +from google.cloud import asset_v1 + + +def sample_list_saved_queries(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.ListSavedQueriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_saved_queries(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudasset_v1_generated_AssetService_ListSavedQueries_sync] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_async.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_async.py new file mode 100644 index 00000000..874aa769 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_async.py @@ -0,0 +1,44 @@ +# -*- 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 UpdateSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_UpdateSavedQuery_async] +from google.cloud import asset_v1 + + +async def sample_update_saved_query(): + # Create a client + client = asset_v1.AssetServiceAsyncClient() + + # Initialize request argument(s) + request = asset_v1.UpdateSavedQueryRequest( + ) + + # Make the request + response = await client.update_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_UpdateSavedQuery_async] diff --git a/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_sync.py b/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_sync.py new file mode 100644 index 00000000..0069cc66 --- /dev/null +++ b/samples/generated_samples/cloudasset_v1_generated_asset_service_update_saved_query_sync.py @@ -0,0 +1,44 @@ +# -*- 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 UpdateSavedQuery +# 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-asset + + +# [START cloudasset_v1_generated_AssetService_UpdateSavedQuery_sync] +from google.cloud import asset_v1 + + +def sample_update_saved_query(): + # Create a client + client = asset_v1.AssetServiceClient() + + # Initialize request argument(s) + request = asset_v1.UpdateSavedQueryRequest( + ) + + # Make the request + response = client.update_saved_query(request=request) + + # Handle the response + print(response) + +# [END cloudasset_v1_generated_AssetService_UpdateSavedQuery_sync] diff --git a/samples/generated_samples/snippet_metadata_asset_v1.json b/samples/generated_samples/snippet_metadata_asset_v1.json index 75479410..239016eb 100644 --- a/samples/generated_samples/snippet_metadata_asset_v1.json +++ b/samples/generated_samples/snippet_metadata_asset_v1.json @@ -622,6 +622,159 @@ ], "title": "cloudasset_v1_generated_asset_service_batch_get_assets_history_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.batch_get_effective_iam_policies", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "BatchGetEffectiveIamPolicies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse", + "shortName": "batch_get_effective_iam_policies" + }, + "description": "Sample for BatchGetEffectiveIamPolicies", + "file": "cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.batch_get_effective_iam_policies", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.BatchGetEffectiveIamPolicies", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "BatchGetEffectiveIamPolicies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse", + "shortName": "batch_get_effective_iam_policies" + }, + "description": "Sample for BatchGetEffectiveIamPolicies", + "file": "cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_batch_get_effective_iam_policies_sync.py" + }, { "canonical": true, "clientMethod": { @@ -632,21 +785,665 @@ }, "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.create_feed", "method": { - "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", + "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "CreateFeed" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "create_feed" + }, + "description": "Sample for CreateFeed", + "file": "cloudasset_v1_generated_asset_service_create_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_create_feed_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.create_feed", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "CreateFeed" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateFeedRequest" + }, + { + "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.asset_v1.types.Feed", + "shortName": "create_feed" + }, + "description": "Sample for CreateFeed", + "file": "cloudasset_v1_generated_asset_service_create_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_create_feed_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.create_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.CreateSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "CreateSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateSavedQueryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "saved_query", + "type": "google.cloud.asset_v1.types.SavedQuery" + }, + { + "name": "saved_query_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.SavedQuery", + "shortName": "create_saved_query" + }, + "description": "Sample for CreateSavedQuery", + "file": "cloudasset_v1_generated_asset_service_create_saved_query_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_CreateSavedQuery_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_create_saved_query_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.create_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.CreateSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "CreateSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.CreateSavedQueryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "saved_query", + "type": "google.cloud.asset_v1.types.SavedQuery" + }, + { + "name": "saved_query_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.asset_v1.types.SavedQuery", + "shortName": "create_saved_query" + }, + "description": "Sample for CreateSavedQuery", + "file": "cloudasset_v1_generated_asset_service_create_saved_query_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_CreateSavedQuery_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_create_saved_query_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.delete_feed", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "DeleteFeed" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + }, + { + "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_feed" + }, + "description": "Sample for DeleteFeed", + "file": "cloudasset_v1_generated_asset_service_delete_feed_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_delete_feed_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.delete_feed", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "DeleteFeed" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + }, + { + "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_feed" + }, + "description": "Sample for DeleteFeed", + "file": "cloudasset_v1_generated_asset_service_delete_feed_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_delete_feed_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.delete_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "DeleteSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteSavedQueryRequest" + }, + { + "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_saved_query" + }, + "description": "Sample for DeleteSavedQuery", + "file": "cloudasset_v1_generated_asset_service_delete_saved_query_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_DeleteSavedQuery_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_delete_saved_query_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.delete_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.DeleteSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "DeleteSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.DeleteSavedQueryRequest" + }, + { + "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_saved_query" + }, + "description": "Sample for DeleteSavedQuery", + "file": "cloudasset_v1_generated_asset_service_delete_saved_query_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_DeleteSavedQuery_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_delete_saved_query_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.export_assets", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "CreateFeed" + "shortName": "ExportAssets" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.CreateFeedRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.asset_v1.types.ExportAssetsRequest" }, { "name": "retry", @@ -661,22 +1458,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.Feed", - "shortName": "create_feed" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_assets" }, - "description": "Sample for CreateFeed", - "file": "cloudasset_v1_generated_asset_service_create_feed_async.py", + "description": "Sample for ExportAssets", + "file": "cloudasset_v1_generated_asset_service_export_assets_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_async", + "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_async", "segments": [ { - "end": 49, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 52, "start": 27, "type": "SHORT" }, @@ -686,22 +1483,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 49, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_create_feed_async.py" + "title": "cloudasset_v1_generated_asset_service_export_assets_async.py" }, { "canonical": true, @@ -710,23 +1507,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.create_feed", + "fullName": "google.cloud.asset_v1.AssetServiceClient.export_assets", "method": { - "fullName": "google.cloud.asset.v1.AssetService.CreateFeed", + "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "CreateFeed" + "shortName": "ExportAssets" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.CreateFeedRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.asset_v1.types.ExportAssetsRequest" }, { "name": "retry", @@ -741,22 +1534,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.Feed", - "shortName": "create_feed" + "resultType": "google.api_core.operation.Operation", + "shortName": "export_assets" }, - "description": "Sample for CreateFeed", - "file": "cloudasset_v1_generated_asset_service_create_feed_sync.py", + "description": "Sample for ExportAssets", + "file": "cloudasset_v1_generated_asset_service_export_assets_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_CreateFeed_sync", + "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_sync", "segments": [ { - "end": 49, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 52, "start": 27, "type": "SHORT" }, @@ -766,22 +1559,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 49, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_create_feed_sync.py" + "title": "cloudasset_v1_generated_asset_service_export_assets_sync.py" }, { "canonical": true, @@ -791,19 +1584,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", "shortName": "AssetServiceAsyncClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.delete_feed", + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.get_feed", "method": { - "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", + "fullName": "google.cloud.asset.v1.AssetService.GetFeed", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "DeleteFeed" + "shortName": "GetFeed" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + "type": "google.cloud.asset_v1.types.GetFeedRequest" }, { "name": "name", @@ -822,21 +1615,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_feed" + "resultType": "google.cloud.asset_v1.types.Feed", + "shortName": "get_feed" }, - "description": "Sample for DeleteFeed", - "file": "cloudasset_v1_generated_asset_service_delete_feed_async.py", + "description": "Sample for GetFeed", + "file": "cloudasset_v1_generated_asset_service_get_feed_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_async", + "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_async", "segments": [ { - "end": 42, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 44, "start": 27, "type": "SHORT" }, @@ -851,15 +1645,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_delete_feed_async.py" + "title": "cloudasset_v1_generated_asset_service_get_feed_async.py" }, { "canonical": true, @@ -868,19 +1664,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.delete_feed", + "fullName": "google.cloud.asset_v1.AssetServiceClient.get_feed", "method": { - "fullName": "google.cloud.asset.v1.AssetService.DeleteFeed", + "fullName": "google.cloud.asset.v1.AssetService.GetFeed", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "DeleteFeed" + "shortName": "GetFeed" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.DeleteFeedRequest" + "type": "google.cloud.asset_v1.types.GetFeedRequest" }, { "name": "name", @@ -899,21 +1695,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_feed" + "resultType": "google.cloud.asset_v1.types.Feed", + "shortName": "get_feed" }, - "description": "Sample for DeleteFeed", - "file": "cloudasset_v1_generated_asset_service_delete_feed_sync.py", + "description": "Sample for GetFeed", + "file": "cloudasset_v1_generated_asset_service_get_feed_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_DeleteFeed_sync", + "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_sync", "segments": [ { - "end": 42, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 44, "start": 27, "type": "SHORT" }, @@ -928,15 +1725,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_delete_feed_sync.py" + "title": "cloudasset_v1_generated_asset_service_get_feed_sync.py" }, { "canonical": true, @@ -946,19 +1745,23 @@ "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", "shortName": "AssetServiceAsyncClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.export_assets", + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.get_saved_query", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", + "fullName": "google.cloud.asset.v1.AssetService.GetSavedQuery", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ExportAssets" + "shortName": "GetSavedQuery" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ExportAssetsRequest" + "type": "google.cloud.asset_v1.types.GetSavedQueryRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -973,22 +1776,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "export_assets" + "resultType": "google.cloud.asset_v1.types.SavedQuery", + "shortName": "get_saved_query" }, - "description": "Sample for ExportAssets", - "file": "cloudasset_v1_generated_asset_service_export_assets_async.py", + "description": "Sample for GetSavedQuery", + "file": "cloudasset_v1_generated_asset_service_get_saved_query_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_async", + "regionTag": "cloudasset_v1_generated_AssetService_GetSavedQuery_async", "segments": [ { - "end": 52, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 44, "start": 27, "type": "SHORT" }, @@ -998,22 +1801,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 42, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 43, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_export_assets_async.py" + "title": "cloudasset_v1_generated_asset_service_get_saved_query_async.py" }, { "canonical": true, @@ -1022,19 +1825,23 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.export_assets", + "fullName": "google.cloud.asset_v1.AssetServiceClient.get_saved_query", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ExportAssets", + "fullName": "google.cloud.asset.v1.AssetService.GetSavedQuery", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ExportAssets" + "shortName": "GetSavedQuery" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ExportAssetsRequest" + "type": "google.cloud.asset_v1.types.GetSavedQueryRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1049,22 +1856,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "export_assets" + "resultType": "google.cloud.asset_v1.types.SavedQuery", + "shortName": "get_saved_query" }, - "description": "Sample for ExportAssets", - "file": "cloudasset_v1_generated_asset_service_export_assets_sync.py", + "description": "Sample for GetSavedQuery", + "file": "cloudasset_v1_generated_asset_service_get_saved_query_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ExportAssets_sync", + "regionTag": "cloudasset_v1_generated_AssetService_GetSavedQuery_sync", "segments": [ { - "end": 52, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 44, "start": 27, "type": "SHORT" }, @@ -1074,22 +1881,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 42, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 43, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_export_assets_sync.py" + "title": "cloudasset_v1_generated_asset_service_get_saved_query_sync.py" }, { "canonical": true, @@ -1099,22 +1906,22 @@ "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", "shortName": "AssetServiceAsyncClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.get_feed", + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_assets", "method": { - "fullName": "google.cloud.asset.v1.AssetService.GetFeed", + "fullName": "google.cloud.asset.v1.AssetService.ListAssets", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "GetFeed" + "shortName": "ListAssets" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.GetFeedRequest" + "type": "google.cloud.asset_v1.types.ListAssetsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -1130,22 +1937,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.Feed", - "shortName": "get_feed" + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsAsyncPager", + "shortName": "list_assets" }, - "description": "Sample for GetFeed", - "file": "cloudasset_v1_generated_asset_service_get_feed_async.py", + "description": "Sample for ListAssets", + "file": "cloudasset_v1_generated_asset_service_list_assets_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_async", + "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -1165,12 +1972,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_get_feed_async.py" + "title": "cloudasset_v1_generated_asset_service_list_assets_async.py" }, { "canonical": true, @@ -1179,22 +1986,22 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.get_feed", + "fullName": "google.cloud.asset_v1.AssetServiceClient.list_assets", "method": { - "fullName": "google.cloud.asset.v1.AssetService.GetFeed", + "fullName": "google.cloud.asset.v1.AssetService.ListAssets", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "GetFeed" + "shortName": "ListAssets" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.GetFeedRequest" + "type": "google.cloud.asset_v1.types.ListAssetsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -1210,22 +2017,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.Feed", - "shortName": "get_feed" + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsPager", + "shortName": "list_assets" }, - "description": "Sample for GetFeed", - "file": "cloudasset_v1_generated_asset_service_get_feed_sync.py", + "description": "Sample for ListAssets", + "file": "cloudasset_v1_generated_asset_service_list_assets_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_GetFeed_sync", + "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -1245,12 +2052,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_get_feed_sync.py" + "title": "cloudasset_v1_generated_asset_service_list_assets_sync.py" }, { "canonical": true, @@ -1260,19 +2067,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", "shortName": "AssetServiceAsyncClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_assets", + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_feeds", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ListAssets", + "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ListAssets" + "shortName": "ListFeeds" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ListAssetsRequest" + "type": "google.cloud.asset_v1.types.ListFeedsRequest" }, { "name": "parent", @@ -1291,22 +2098,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsAsyncPager", - "shortName": "list_assets" + "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", + "shortName": "list_feeds" }, - "description": "Sample for ListAssets", - "file": "cloudasset_v1_generated_asset_service_list_assets_async.py", + "description": "Sample for ListFeeds", + "file": "cloudasset_v1_generated_asset_service_list_feeds_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_async", + "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_async", "segments": [ { - "end": 45, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 44, "start": 27, "type": "SHORT" }, @@ -1326,12 +2133,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 46, + "end": 45, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_list_assets_async.py" + "title": "cloudasset_v1_generated_asset_service_list_feeds_async.py" }, { "canonical": true, @@ -1340,19 +2147,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.list_assets", + "fullName": "google.cloud.asset_v1.AssetServiceClient.list_feeds", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ListAssets", + "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ListAssets" + "shortName": "ListFeeds" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ListAssetsRequest" + "type": "google.cloud.asset_v1.types.ListFeedsRequest" }, { "name": "parent", @@ -1371,22 +2178,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsPager", - "shortName": "list_assets" + "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", + "shortName": "list_feeds" }, - "description": "Sample for ListAssets", - "file": "cloudasset_v1_generated_asset_service_list_assets_sync.py", + "description": "Sample for ListFeeds", + "file": "cloudasset_v1_generated_asset_service_list_feeds_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ListAssets_sync", + "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_sync", "segments": [ { - "end": 45, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 44, "start": 27, "type": "SHORT" }, @@ -1406,12 +2213,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 46, + "end": 45, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_list_assets_sync.py" + "title": "cloudasset_v1_generated_asset_service_list_feeds_sync.py" }, { "canonical": true, @@ -1421,19 +2228,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", "shortName": "AssetServiceAsyncClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_feeds", + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.list_saved_queries", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", + "fullName": "google.cloud.asset.v1.AssetService.ListSavedQueries", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ListFeeds" + "shortName": "ListSavedQueries" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ListFeedsRequest" + "type": "google.cloud.asset_v1.types.ListSavedQueriesRequest" }, { "name": "parent", @@ -1452,22 +2259,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", - "shortName": "list_feeds" + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesAsyncPager", + "shortName": "list_saved_queries" }, - "description": "Sample for ListFeeds", - "file": "cloudasset_v1_generated_asset_service_list_feeds_async.py", + "description": "Sample for ListSavedQueries", + "file": "cloudasset_v1_generated_asset_service_list_saved_queries_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_async", + "regionTag": "cloudasset_v1_generated_AssetService_ListSavedQueries_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -1487,12 +2294,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_list_feeds_async.py" + "title": "cloudasset_v1_generated_asset_service_list_saved_queries_async.py" }, { "canonical": true, @@ -1501,19 +2308,19 @@ "fullName": "google.cloud.asset_v1.AssetServiceClient", "shortName": "AssetServiceClient" }, - "fullName": "google.cloud.asset_v1.AssetServiceClient.list_feeds", + "fullName": "google.cloud.asset_v1.AssetServiceClient.list_saved_queries", "method": { - "fullName": "google.cloud.asset.v1.AssetService.ListFeeds", + "fullName": "google.cloud.asset.v1.AssetService.ListSavedQueries", "service": { "fullName": "google.cloud.asset.v1.AssetService", "shortName": "AssetService" }, - "shortName": "ListFeeds" + "shortName": "ListSavedQueries" }, "parameters": [ { "name": "request", - "type": "google.cloud.asset_v1.types.ListFeedsRequest" + "type": "google.cloud.asset_v1.types.ListSavedQueriesRequest" }, { "name": "parent", @@ -1532,22 +2339,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", - "shortName": "list_feeds" + "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesPager", + "shortName": "list_saved_queries" }, - "description": "Sample for ListFeeds", - "file": "cloudasset_v1_generated_asset_service_list_feeds_sync.py", + "description": "Sample for ListSavedQueries", + "file": "cloudasset_v1_generated_asset_service_list_saved_queries_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "cloudasset_v1_generated_AssetService_ListFeeds_sync", + "regionTag": "cloudasset_v1_generated_AssetService_ListSavedQueries_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -1567,12 +2374,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "cloudasset_v1_generated_asset_service_list_feeds_sync.py" + "title": "cloudasset_v1_generated_asset_service_list_saved_queries_sync.py" }, { "canonical": true, @@ -2080,6 +2887,175 @@ } ], "title": "cloudasset_v1_generated_asset_service_update_feed_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient", + "shortName": "AssetServiceAsyncClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceAsyncClient.update_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.UpdateSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "UpdateSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.UpdateSavedQueryRequest" + }, + { + "name": "saved_query", + "type": "google.cloud.asset_v1.types.SavedQuery" + }, + { + "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.asset_v1.types.SavedQuery", + "shortName": "update_saved_query" + }, + "description": "Sample for UpdateSavedQuery", + "file": "cloudasset_v1_generated_asset_service_update_saved_query_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_UpdateSavedQuery_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_update_saved_query_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.asset_v1.AssetServiceClient", + "shortName": "AssetServiceClient" + }, + "fullName": "google.cloud.asset_v1.AssetServiceClient.update_saved_query", + "method": { + "fullName": "google.cloud.asset.v1.AssetService.UpdateSavedQuery", + "service": { + "fullName": "google.cloud.asset.v1.AssetService", + "shortName": "AssetService" + }, + "shortName": "UpdateSavedQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.asset_v1.types.UpdateSavedQueryRequest" + }, + { + "name": "saved_query", + "type": "google.cloud.asset_v1.types.SavedQuery" + }, + { + "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.asset_v1.types.SavedQuery", + "shortName": "update_saved_query" + }, + "description": "Sample for UpdateSavedQuery", + "file": "cloudasset_v1_generated_asset_service_update_saved_query_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudasset_v1_generated_AssetService_UpdateSavedQuery_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudasset_v1_generated_asset_service_update_saved_query_sync.py" } ] } diff --git a/scripts/fixup_asset_v1_keywords.py b/scripts/fixup_asset_v1_keywords.py index 5bdce0c3..946a8cac 100644 --- a/scripts/fixup_asset_v1_keywords.py +++ b/scripts/fixup_asset_v1_keywords.py @@ -39,19 +39,25 @@ def partition( class assetCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'analyze_iam_policy': ('analysis_query', 'execution_timeout', ), - 'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ), + 'analyze_iam_policy': ('analysis_query', 'saved_analysis_query', 'execution_timeout', ), + 'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', 'saved_analysis_query', ), 'analyze_move': ('resource', 'destination_parent', 'view', ), 'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', 'relationship_types', ), + 'batch_get_effective_iam_policies': ('scope', 'names', ), 'create_feed': ('parent', 'feed_id', 'feed', ), + 'create_saved_query': ('parent', 'saved_query', 'saved_query_id', ), 'delete_feed': ('name', ), + 'delete_saved_query': ('name', ), 'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', 'relationship_types', ), 'get_feed': ('name', ), + 'get_saved_query': ('name', ), 'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', 'relationship_types', ), 'list_feeds': ('parent', ), + 'list_saved_queries': ('parent', 'filter', 'page_size', 'page_token', ), 'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ), 'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', 'read_mask', ), 'update_feed': ('feed', 'update_mask', ), + 'update_saved_query': ('saved_query', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/unit/gapic/asset_v1/test_asset_service.py index 642cb700..c782757e 100644 --- a/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1/test_asset_service.py @@ -3914,6 +3914,1627 @@ async def test_analyze_move_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + asset_service.CreateSavedQueryRequest, + dict, + ], +) +def test_create_saved_query(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + response = client.create_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.CreateSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +def test_create_saved_query_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + client.create_saved_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.CreateSavedQueryRequest() + + +@pytest.mark.asyncio +async def test_create_saved_query_async( + transport: str = "grpc_asyncio", request_type=asset_service.CreateSavedQueryRequest +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + ) + response = await client.create_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.CreateSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +@pytest.mark.asyncio +async def test_create_saved_query_async_from_dict(): + await test_create_saved_query_async(request_type=dict) + + +def test_create_saved_query_field_headers(): + client = AssetServiceClient( + 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 = asset_service.CreateSavedQueryRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + call.return_value = asset_service.SavedQuery() + client.create_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_saved_query_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.CreateSavedQueryRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + await client.create_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_saved_query_flattened(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_saved_query( + parent="parent_value", + saved_query=asset_service.SavedQuery(name="name_value"), + saved_query_id="saved_query_id_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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].saved_query + mock_val = asset_service.SavedQuery(name="name_value") + assert arg == mock_val + arg = args[0].saved_query_id + mock_val = "saved_query_id_value" + assert arg == mock_val + + +def test_create_saved_query_flattened_error(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_saved_query( + asset_service.CreateSavedQueryRequest(), + parent="parent_value", + saved_query=asset_service.SavedQuery(name="name_value"), + saved_query_id="saved_query_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_saved_query_flattened_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_saved_query( + parent="parent_value", + saved_query=asset_service.SavedQuery(name="name_value"), + saved_query_id="saved_query_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].saved_query + mock_val = asset_service.SavedQuery(name="name_value") + assert arg == mock_val + arg = args[0].saved_query_id + mock_val = "saved_query_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_saved_query_flattened_error_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_saved_query( + asset_service.CreateSavedQueryRequest(), + parent="parent_value", + saved_query=asset_service.SavedQuery(name="name_value"), + saved_query_id="saved_query_id_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + asset_service.GetSavedQueryRequest, + dict, + ], +) +def test_get_saved_query(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + response = client.get_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.GetSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +def test_get_saved_query_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + client.get_saved_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.GetSavedQueryRequest() + + +@pytest.mark.asyncio +async def test_get_saved_query_async( + transport: str = "grpc_asyncio", request_type=asset_service.GetSavedQueryRequest +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + ) + response = await client.get_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.GetSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +@pytest.mark.asyncio +async def test_get_saved_query_async_from_dict(): + await test_get_saved_query_async(request_type=dict) + + +def test_get_saved_query_field_headers(): + client = AssetServiceClient( + 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 = asset_service.GetSavedQueryRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + call.return_value = asset_service.SavedQuery() + client.get_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_saved_query_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.GetSavedQueryRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + await client.get_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_saved_query_flattened(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_saved_query( + name="name_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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_saved_query_flattened_error(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_saved_query( + asset_service.GetSavedQueryRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_saved_query_flattened_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_saved_query), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_saved_query( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_saved_query_flattened_error_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_saved_query( + asset_service.GetSavedQueryRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + asset_service.ListSavedQueriesRequest, + dict, + ], +) +def test_list_saved_queries(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.ListSavedQueriesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_saved_queries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.ListSavedQueriesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSavedQueriesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_saved_queries_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + client.list_saved_queries() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.ListSavedQueriesRequest() + + +@pytest.mark.asyncio +async def test_list_saved_queries_async( + transport: str = "grpc_asyncio", request_type=asset_service.ListSavedQueriesRequest +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.ListSavedQueriesResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_saved_queries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.ListSavedQueriesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSavedQueriesAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_saved_queries_async_from_dict(): + await test_list_saved_queries_async(request_type=dict) + + +def test_list_saved_queries_field_headers(): + client = AssetServiceClient( + 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 = asset_service.ListSavedQueriesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + call.return_value = asset_service.ListSavedQueriesResponse() + client.list_saved_queries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_saved_queries_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.ListSavedQueriesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.ListSavedQueriesResponse() + ) + await client.list_saved_queries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_saved_queries_flattened(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.ListSavedQueriesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_saved_queries( + parent="parent_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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_saved_queries_flattened_error(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_saved_queries( + asset_service.ListSavedQueriesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_saved_queries_flattened_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.ListSavedQueriesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.ListSavedQueriesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_saved_queries( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_saved_queries_flattened_error_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_saved_queries( + asset_service.ListSavedQueriesRequest(), + parent="parent_value", + ) + + +def test_list_saved_queries_pager(transport_name: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + next_page_token="abc", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[], + next_page_token="def", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + ], + next_page_token="ghi", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_saved_queries(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, asset_service.SavedQuery) for i in results) + + +def test_list_saved_queries_pages(transport_name: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + next_page_token="abc", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[], + next_page_token="def", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + ], + next_page_token="ghi", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + ), + RuntimeError, + ) + pages = list(client.list_saved_queries(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_saved_queries_async_pager(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + next_page_token="abc", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[], + next_page_token="def", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + ], + next_page_token="ghi", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_saved_queries( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, asset_service.SavedQuery) for i in responses) + + +@pytest.mark.asyncio +async def test_list_saved_queries_async_pages(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_saved_queries), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + next_page_token="abc", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[], + next_page_token="def", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + ], + next_page_token="ghi", + ), + asset_service.ListSavedQueriesResponse( + saved_queries=[ + asset_service.SavedQuery(), + asset_service.SavedQuery(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_saved_queries(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 + + +@pytest.mark.parametrize( + "request_type", + [ + asset_service.UpdateSavedQueryRequest, + dict, + ], +) +def test_update_saved_query(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + response = client.update_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.UpdateSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +def test_update_saved_query_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + client.update_saved_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.UpdateSavedQueryRequest() + + +@pytest.mark.asyncio +async def test_update_saved_query_async( + transport: str = "grpc_asyncio", request_type=asset_service.UpdateSavedQueryRequest +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery( + name="name_value", + description="description_value", + creator="creator_value", + last_updater="last_updater_value", + ) + ) + response = await client.update_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.UpdateSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.SavedQuery) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.creator == "creator_value" + assert response.last_updater == "last_updater_value" + + +@pytest.mark.asyncio +async def test_update_saved_query_async_from_dict(): + await test_update_saved_query_async(request_type=dict) + + +def test_update_saved_query_field_headers(): + client = AssetServiceClient( + 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 = asset_service.UpdateSavedQueryRequest() + + request.saved_query.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + call.return_value = asset_service.SavedQuery() + client.update_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "saved_query.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_saved_query_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.UpdateSavedQueryRequest() + + request.saved_query.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + await client.update_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "saved_query.name=name_value", + ) in kw["metadata"] + + +def test_update_saved_query_flattened(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_saved_query( + saved_query=asset_service.SavedQuery(name="name_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] + arg = args[0].saved_query + mock_val = asset_service.SavedQuery(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_saved_query_flattened_error(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_saved_query( + asset_service.UpdateSavedQueryRequest(), + saved_query=asset_service.SavedQuery(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_saved_query_flattened_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.SavedQuery() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.SavedQuery() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_saved_query( + saved_query=asset_service.SavedQuery(name="name_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] + arg = args[0].saved_query + mock_val = asset_service.SavedQuery(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_saved_query_flattened_error_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_saved_query( + asset_service.UpdateSavedQueryRequest(), + saved_query=asset_service.SavedQuery(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + asset_service.DeleteSavedQueryRequest, + dict, + ], +) +def test_delete_saved_query(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.DeleteSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_saved_query_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + client.delete_saved_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.DeleteSavedQueryRequest() + + +@pytest.mark.asyncio +async def test_delete_saved_query_async( + transport: str = "grpc_asyncio", request_type=asset_service.DeleteSavedQueryRequest +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.DeleteSavedQueryRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_saved_query_async_from_dict(): + await test_delete_saved_query_async(request_type=dict) + + +def test_delete_saved_query_field_headers(): + client = AssetServiceClient( + 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 = asset_service.DeleteSavedQueryRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + call.return_value = None + client.delete_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_saved_query_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.DeleteSavedQueryRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_saved_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_saved_query_flattened(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__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_saved_query( + name="name_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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_saved_query_flattened_error(): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_saved_query( + asset_service.DeleteSavedQueryRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_saved_query_flattened_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_saved_query), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_saved_query( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_saved_query_flattened_error_async(): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_saved_query( + asset_service.DeleteSavedQueryRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + asset_service.BatchGetEffectiveIamPoliciesRequest, + dict, + ], +) +def test_batch_get_effective_iam_policies(request_type, transport: str = "grpc"): + client = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_effective_iam_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = asset_service.BatchGetEffectiveIamPoliciesResponse() + response = client.batch_get_effective_iam_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.BatchGetEffectiveIamPoliciesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.BatchGetEffectiveIamPoliciesResponse) + + +def test_batch_get_effective_iam_policies_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 = AssetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_effective_iam_policies), "__call__" + ) as call: + client.batch_get_effective_iam_policies() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.BatchGetEffectiveIamPoliciesRequest() + + +@pytest.mark.asyncio +async def test_batch_get_effective_iam_policies_async( + transport: str = "grpc_asyncio", + request_type=asset_service.BatchGetEffectiveIamPoliciesRequest, +): + client = AssetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_effective_iam_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.BatchGetEffectiveIamPoliciesResponse() + ) + response = await client.batch_get_effective_iam_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == asset_service.BatchGetEffectiveIamPoliciesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, asset_service.BatchGetEffectiveIamPoliciesResponse) + + +@pytest.mark.asyncio +async def test_batch_get_effective_iam_policies_async_from_dict(): + await test_batch_get_effective_iam_policies_async(request_type=dict) + + +def test_batch_get_effective_iam_policies_field_headers(): + client = AssetServiceClient( + 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 = asset_service.BatchGetEffectiveIamPoliciesRequest() + + request.scope = "scope_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_effective_iam_policies), "__call__" + ) as call: + call.return_value = asset_service.BatchGetEffectiveIamPoliciesResponse() + client.batch_get_effective_iam_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "scope=scope_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_get_effective_iam_policies_field_headers_async(): + client = AssetServiceAsyncClient( + 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 = asset_service.BatchGetEffectiveIamPoliciesRequest() + + request.scope = "scope_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_effective_iam_policies), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + asset_service.BatchGetEffectiveIamPoliciesResponse() + ) + await client.batch_get_effective_iam_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "scope=scope_value", + ) in kw["metadata"] + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.AssetServiceGrpcTransport( @@ -4064,6 +5685,12 @@ def test_asset_service_base_transport(): "analyze_iam_policy", "analyze_iam_policy_longrunning", "analyze_move", + "create_saved_query", + "get_saved_query", + "list_saved_queries", + "update_saved_query", + "delete_saved_query", + "batch_get_effective_iam_policies", ) for method in methods: with pytest.raises(NotImplementedError): @@ -4515,9 +6142,32 @@ def test_parse_inventory_path(): assert expected == actual +def test_saved_query_path(): + project = "oyster" + saved_query = "nudibranch" + expected = "projects/{project}/savedQueries/{saved_query}".format( + project=project, + saved_query=saved_query, + ) + actual = AssetServiceClient.saved_query_path(project, saved_query) + assert expected == actual + + +def test_parse_saved_query_path(): + expected = { + "project": "cuttlefish", + "saved_query": "mussel", + } + path = AssetServiceClient.saved_query_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_saved_query_path(path) + assert expected == actual + + def test_service_perimeter_path(): - access_policy = "oyster" - service_perimeter = "nudibranch" + access_policy = "winkle" + service_perimeter = "nautilus" expected = ( "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( access_policy=access_policy, @@ -4530,8 +6180,8 @@ def test_service_perimeter_path(): def test_parse_service_perimeter_path(): expected = { - "access_policy": "cuttlefish", - "service_perimeter": "mussel", + "access_policy": "scallop", + "service_perimeter": "abalone", } path = AssetServiceClient.service_perimeter_path(**expected) @@ -4541,7 +6191,7 @@ def test_parse_service_perimeter_path(): def test_common_billing_account_path(): - billing_account = "winkle" + billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4551,7 +6201,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nautilus", + "billing_account": "clam", } path = AssetServiceClient.common_billing_account_path(**expected) @@ -4561,7 +6211,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "scallop" + folder = "whelk" expected = "folders/{folder}".format( folder=folder, ) @@ -4571,7 +6221,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "abalone", + "folder": "octopus", } path = AssetServiceClient.common_folder_path(**expected) @@ -4581,7 +6231,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "squid" + organization = "oyster" expected = "organizations/{organization}".format( organization=organization, ) @@ -4591,7 +6241,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "clam", + "organization": "nudibranch", } path = AssetServiceClient.common_organization_path(**expected) @@ -4601,7 +6251,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "whelk" + project = "cuttlefish" expected = "projects/{project}".format( project=project, ) @@ -4611,7 +6261,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "octopus", + "project": "mussel", } path = AssetServiceClient.common_project_path(**expected) @@ -4621,8 +6271,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "oyster" - location = "nudibranch" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -4633,8 +6283,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "cuttlefish", - "location": "mussel", + "project": "scallop", + "location": "abalone", } path = AssetServiceClient.common_location_path(**expected) From d498989ec1f7807cb3b611bcc61b78805bd48cff Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 08:35:44 -0400 Subject: [PATCH 30/30] chore(main): release 3.9.0 (#426) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9000b0f..d0255679 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-asset/#history +## [3.9.0](https://github.com/googleapis/python-asset/compare/v3.8.1...v3.9.0) (2022-05-19) + + +### Features + +* Add SavedQuery CURD support ([#425](https://github.com/googleapis/python-asset/issues/425)) ([b3e5650](https://github.com/googleapis/python-asset/commit/b3e5650732e46c4c6ee7835cdfa38c1232efb3b9)) + ### [3.8.1](https://github.com/googleapis/python-asset/compare/v3.8.0...v3.8.1) (2022-03-05) diff --git a/setup.py b/setup.py index 806f6554..0b98963d 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ name = "google-cloud-asset" description = "Cloud Asset API API client library" -version = "3.8.1" +version = "3.9.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'