From 0ae24132b6d9591ae393bb08c6b158addeaa8c9e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 00:02:23 +0000 Subject: [PATCH] chore(python): use black==22.3.0 (#139) 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 | 5 +- .../assured_workloads_service/async_client.py | 38 ++- .../assured_workloads_service/client.py | 87 ++++- .../transports/base.py | 26 +- .../transports/grpc.py | 3 +- .../types/assuredworkloads.py | 201 ++++++++--- .../assured_workloads_service/async_client.py | 38 ++- .../assured_workloads_service/client.py | 87 ++++- .../transports/base.py | 14 +- .../transports/grpc.py | 3 +- .../types/assuredworkloads_v1beta1.py | 221 +++++++++--- .../google-cloud-assured-workloads/noxfile.py | 9 +- .../test_assured_workloads_service.py | 322 +++++++++++++----- .../test_assured_workloads_service.py | 298 +++++++++++----- 15 files changed, 1035 insertions(+), 319 deletions(-) diff --git a/packages/google-cloud-assured-workloads/.github/.OwlBot.lock.yaml b/packages/google-cloud-assured-workloads/.github/.OwlBot.lock.yaml index 44c78f7cc12d..87dd00611576 100644 --- a/packages/google-cloud-assured-workloads/.github/.OwlBot.lock.yaml +++ b/packages/google-cloud-assured-workloads/.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/packages/google-cloud-assured-workloads/docs/conf.py b/packages/google-cloud-assured-workloads/docs/conf.py index 497b6d2f7ac4..a86bfa0fb36c 100644 --- a/packages/google-cloud-assured-workloads/docs/conf.py +++ b/packages/google-cloud-assured-workloads/docs/conf.py @@ -361,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/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py index f49fa553314c..14ca4fbc74bf 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py @@ -318,7 +318,12 @@ def sample_create_workload(): ) # 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( @@ -439,7 +444,12 @@ def sample_update_workload(): ) # 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 @@ -524,7 +534,10 @@ def sample_delete_workload(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_workload( @@ -616,7 +629,12 @@ def sample_get_workload(): ) # 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 @@ -710,12 +728,20 @@ def sample_list_workloads(): ) # 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.ListWorkloadsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py index d4efdb383d4e..3ee8ffcaf838 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py @@ -60,7 +60,8 @@ class AssuredWorkloadsServiceClientMeta(type): _transport_registry["grpc_asyncio"] = AssuredWorkloadsServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[AssuredWorkloadsServiceTransport]: """Returns an appropriate transport class. @@ -166,10 +167,16 @@ def transport(self) -> AssuredWorkloadsServiceTransport: return self._transport @staticmethod - def workload_path(organization: str, location: str, workload: str,) -> str: + def workload_path( + organization: str, + location: str, + workload: str, + ) -> str: """Returns a fully-qualified workload string.""" return "organizations/{organization}/locations/{location}/workloads/{workload}".format( - organization=organization, location=location, workload=workload, + organization=organization, + location=location, + workload=workload, ) @staticmethod @@ -182,7 +189,9 @@ def parse_workload_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, @@ -195,9 +204,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]: @@ -206,9 +219,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]: @@ -217,9 +234,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]: @@ -228,10 +249,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 @@ -510,7 +535,12 @@ def sample_create_workload(): ) # 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( @@ -631,7 +661,12 @@ def sample_update_workload(): ) # 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 @@ -716,7 +751,10 @@ def sample_delete_workload(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_workload( @@ -808,7 +846,12 @@ def sample_get_workload(): ) # 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 @@ -902,12 +945,20 @@ def sample_list_workloads(): ) # 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.ListWorkloadsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/base.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/base.py index c2b3cc71a52a..51408425da8c 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/base.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/base.py @@ -124,28 +124,38 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_workload: gapic_v1.method.wrap_method( - self.create_workload, default_timeout=None, client_info=client_info, + self.create_workload, + default_timeout=None, + client_info=client_info, ), self.update_workload: gapic_v1.method.wrap_method( - self.update_workload, default_timeout=None, client_info=client_info, + self.update_workload, + default_timeout=None, + client_info=client_info, ), self.delete_workload: gapic_v1.method.wrap_method( - self.delete_workload, default_timeout=None, client_info=client_info, + self.delete_workload, + default_timeout=None, + client_info=client_info, ), self.get_workload: gapic_v1.method.wrap_method( - self.get_workload, default_timeout=None, client_info=client_info, + self.get_workload, + default_timeout=None, + client_info=client_info, ), self.list_workloads: gapic_v1.method.wrap_method( - self.list_workloads, default_timeout=None, client_info=client_info, + self.list_workloads, + 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/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py index c97251268573..abdabd2f5daf 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/types/assuredworkloads.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/types/assuredworkloads.py index 689c6c7be09d..39cd61a27067 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/types/assuredworkloads.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/types/assuredworkloads.py @@ -54,9 +54,19 @@ class CreateWorkloadRequest(proto.Message): projects with the identifier as the value. """ - parent = proto.Field(proto.STRING, number=1,) - workload = proto.Field(proto.MESSAGE, number=2, message="Workload",) - external_id = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + workload = proto.Field( + proto.MESSAGE, + number=2, + message="Workload", + ) + external_id = proto.Field( + proto.STRING, + number=3, + ) class UpdateWorkloadRequest(proto.Message): @@ -72,9 +82,15 @@ class UpdateWorkloadRequest(proto.Message): Required. The list of fields to be updated. """ - workload = proto.Field(proto.MESSAGE, number=1, message="Workload",) + workload = proto.Field( + proto.MESSAGE, + number=1, + message="Workload", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -92,8 +108,14 @@ class DeleteWorkloadRequest(proto.Message): etag. """ - name = proto.Field(proto.STRING, number=1,) - etag = proto.Field(proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=1, + ) + etag = proto.Field( + proto.STRING, + number=2, + ) class GetWorkloadRequest(proto.Message): @@ -108,7 +130,10 @@ class GetWorkloadRequest(proto.Message): "organizations/123/locations/us-east1/workloads/assured-workload-1". """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListWorkloadsRequest(proto.Message): @@ -131,10 +156,22 @@ class ListWorkloadsRequest(proto.Message): labels is supported. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListWorkloadsResponse(proto.Message): @@ -152,8 +189,15 @@ class ListWorkloadsResponse(proto.Message): def raw_page(self): return self - workloads = proto.RepeatedField(proto.MESSAGE, number=1, message="Workload",) - next_page_token = proto.Field(proto.STRING, number=2,) + workloads = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Workload", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class Workload(proto.Message): @@ -271,9 +315,14 @@ class ResourceType(proto.Enum): ENCRYPTION_KEYS_PROJECT = 2 KEYRING = 3 - resource_id = proto.Field(proto.INT64, number=1,) + resource_id = proto.Field( + proto.INT64, + number=1, + ) resource_type = proto.Field( - proto.ENUM, number=2, enum="Workload.ResourceInfo.ResourceType", + proto.ENUM, + number=2, + enum="Workload.ResourceInfo.ResourceType", ) class KMSSettings(proto.Message): @@ -293,10 +342,14 @@ class KMSSettings(proto.Message): """ next_rotation_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) rotation_period = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, ) class ResourceSettings(proto.Message): @@ -318,11 +371,19 @@ class ResourceSettings(proto.Message): resource with the specified name. """ - resource_id = proto.Field(proto.STRING, number=1,) + resource_id = proto.Field( + proto.STRING, + number=1, + ) resource_type = proto.Field( - proto.ENUM, number=2, enum="Workload.ResourceInfo.ResourceType", + proto.ENUM, + number=2, + enum="Workload.ResourceInfo.ResourceType", + ) + display_name = proto.Field( + proto.STRING, + number=3, ) - display_name = proto.Field(proto.STRING, number=3,) class SaaEnrollmentResponse(proto.Message): r"""Signed Access Approvals (SAA) enrollment response. @@ -360,26 +421,74 @@ class SetupError(proto.Enum): enum="Workload.SaaEnrollmentResponse.SetupState", ) setup_errors = proto.RepeatedField( - proto.ENUM, number=2, enum="Workload.SaaEnrollmentResponse.SetupError", + proto.ENUM, + number=2, + enum="Workload.SaaEnrollmentResponse.SetupError", ) - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - resources = proto.RepeatedField(proto.MESSAGE, number=3, message=ResourceInfo,) - compliance_regime = proto.Field(proto.ENUM, number=4, enum=ComplianceRegime,) - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - billing_account = proto.Field(proto.STRING, number=6,) - etag = proto.Field(proto.STRING, number=9,) - labels = proto.MapField(proto.STRING, proto.STRING, number=10,) - provisioned_resources_parent = proto.Field(proto.STRING, number=13,) - kms_settings = proto.Field(proto.MESSAGE, number=14, message=KMSSettings,) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=ResourceInfo, + ) + compliance_regime = proto.Field( + proto.ENUM, + number=4, + enum=ComplianceRegime, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + billing_account = proto.Field( + proto.STRING, + number=6, + ) + etag = proto.Field( + proto.STRING, + number=9, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=10, + ) + provisioned_resources_parent = proto.Field( + proto.STRING, + number=13, + ) + kms_settings = proto.Field( + proto.MESSAGE, + number=14, + message=KMSSettings, + ) resource_settings = proto.RepeatedField( - proto.MESSAGE, number=15, message=ResourceSettings, + proto.MESSAGE, + number=15, + message=ResourceSettings, + ) + kaj_enrollment_state = proto.Field( + proto.ENUM, + number=17, + enum=KajEnrollmentState, + ) + enable_sovereign_controls = proto.Field( + proto.BOOL, + number=18, ) - kaj_enrollment_state = proto.Field(proto.ENUM, number=17, enum=KajEnrollmentState,) - enable_sovereign_controls = proto.Field(proto.BOOL, number=18,) saa_enrollment_response = proto.Field( - proto.MESSAGE, number=20, message=SaaEnrollmentResponse, + proto.MESSAGE, + number=20, + message=SaaEnrollmentResponse, ) @@ -400,11 +509,23 @@ class CreateWorkloadOperationMetadata(proto.Message): workload. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - display_name = proto.Field(proto.STRING, number=2,) - parent = proto.Field(proto.STRING, number=3,) + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + parent = proto.Field( + proto.STRING, + number=3, + ) compliance_regime = proto.Field( - proto.ENUM, number=4, enum="Workload.ComplianceRegime", + proto.ENUM, + number=4, + enum="Workload.ComplianceRegime", ) diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py index e1295b303654..7d4cc88e622a 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py @@ -319,7 +319,12 @@ def sample_create_workload(): ) # 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( @@ -439,7 +444,12 @@ def sample_update_workload(): ) # 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 @@ -533,7 +543,10 @@ def sample_delete_workload(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_workload( @@ -634,7 +647,12 @@ def sample_get_workload(): ) # 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 @@ -737,12 +755,20 @@ def sample_list_workloads(): ) # 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.ListWorkloadsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py index 4ad2e9f907c6..928e46a10763 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py @@ -62,7 +62,8 @@ class AssuredWorkloadsServiceClientMeta(type): _transport_registry["grpc_asyncio"] = AssuredWorkloadsServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[AssuredWorkloadsServiceTransport]: """Returns an appropriate transport class. @@ -168,10 +169,16 @@ def transport(self) -> AssuredWorkloadsServiceTransport: return self._transport @staticmethod - def workload_path(organization: str, location: str, workload: str,) -> str: + def workload_path( + organization: str, + location: str, + workload: str, + ) -> str: """Returns a fully-qualified workload string.""" return "organizations/{organization}/locations/{location}/workloads/{workload}".format( - organization=organization, location=location, workload=workload, + organization=organization, + location=location, + workload=workload, ) @staticmethod @@ -184,7 +191,9 @@ def parse_workload_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, @@ -197,9 +206,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]: @@ -208,9 +221,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]: @@ -219,9 +236,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]: @@ -230,10 +251,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 @@ -511,7 +536,12 @@ def sample_create_workload(): ) # 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( @@ -631,7 +661,12 @@ def sample_update_workload(): ) # 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 @@ -716,7 +751,10 @@ def sample_delete_workload(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_workload( @@ -808,7 +846,12 @@ def sample_get_workload(): ) # 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 @@ -902,12 +945,20 @@ def sample_list_workloads(): ) # 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.ListWorkloadsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/base.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/base.py index aa93e6492353..0ff929101a5f 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/base.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/base.py @@ -124,10 +124,14 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_workload: gapic_v1.method.wrap_method( - self.create_workload, default_timeout=60.0, client_info=client_info, + self.create_workload, + default_timeout=60.0, + client_info=client_info, ), self.update_workload: gapic_v1.method.wrap_method( - self.update_workload, default_timeout=60.0, client_info=client_info, + self.update_workload, + default_timeout=60.0, + client_info=client_info, ), self.delete_workload: gapic_v1.method.wrap_method( self.delete_workload, @@ -176,9 +180,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/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py index 066b8c89d9fb..3078d14ebfee 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/types/assuredworkloads_v1beta1.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/types/assuredworkloads_v1beta1.py index 9d69462272e1..141226c3d047 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/types/assuredworkloads_v1beta1.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/types/assuredworkloads_v1beta1.py @@ -54,9 +54,19 @@ class CreateWorkloadRequest(proto.Message): projects with the identifier as the value. """ - parent = proto.Field(proto.STRING, number=1,) - workload = proto.Field(proto.MESSAGE, number=2, message="Workload",) - external_id = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + workload = proto.Field( + proto.MESSAGE, + number=2, + message="Workload", + ) + external_id = proto.Field( + proto.STRING, + number=3, + ) class UpdateWorkloadRequest(proto.Message): @@ -72,9 +82,15 @@ class UpdateWorkloadRequest(proto.Message): Required. The list of fields to be updated. """ - workload = proto.Field(proto.MESSAGE, number=1, message="Workload",) + workload = proto.Field( + proto.MESSAGE, + number=1, + message="Workload", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -92,8 +108,14 @@ class DeleteWorkloadRequest(proto.Message): etag. """ - name = proto.Field(proto.STRING, number=1,) - etag = proto.Field(proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=1, + ) + etag = proto.Field( + proto.STRING, + number=2, + ) class GetWorkloadRequest(proto.Message): @@ -108,7 +130,10 @@ class GetWorkloadRequest(proto.Message): "organizations/123/locations/us-east1/workloads/assured-workload-1". """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListWorkloadsRequest(proto.Message): @@ -131,10 +156,22 @@ class ListWorkloadsRequest(proto.Message): labels is supported. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListWorkloadsResponse(proto.Message): @@ -152,8 +189,15 @@ class ListWorkloadsResponse(proto.Message): def raw_page(self): return self - workloads = proto.RepeatedField(proto.MESSAGE, number=1, message="Workload",) - next_page_token = proto.Field(proto.STRING, number=2,) + workloads = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Workload", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class Workload(proto.Message): @@ -300,9 +344,14 @@ class ResourceType(proto.Enum): ENCRYPTION_KEYS_PROJECT = 2 KEYRING = 3 - resource_id = proto.Field(proto.INT64, number=1,) + resource_id = proto.Field( + proto.INT64, + number=1, + ) resource_type = proto.Field( - proto.ENUM, number=2, enum="Workload.ResourceInfo.ResourceType", + proto.ENUM, + number=2, + enum="Workload.ResourceInfo.ResourceType", ) class KMSSettings(proto.Message): @@ -322,10 +371,14 @@ class KMSSettings(proto.Message): """ next_rotation_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) rotation_period = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, ) class IL4Settings(proto.Message): @@ -338,7 +391,9 @@ class IL4Settings(proto.Message): """ kms_settings = proto.Field( - proto.MESSAGE, number=1, message="Workload.KMSSettings", + proto.MESSAGE, + number=1, + message="Workload.KMSSettings", ) class CJISSettings(proto.Message): @@ -351,7 +406,9 @@ class CJISSettings(proto.Message): """ kms_settings = proto.Field( - proto.MESSAGE, number=1, message="Workload.KMSSettings", + proto.MESSAGE, + number=1, + message="Workload.KMSSettings", ) class FedrampHighSettings(proto.Message): @@ -364,7 +421,9 @@ class FedrampHighSettings(proto.Message): """ kms_settings = proto.Field( - proto.MESSAGE, number=1, message="Workload.KMSSettings", + proto.MESSAGE, + number=1, + message="Workload.KMSSettings", ) class FedrampModerateSettings(proto.Message): @@ -377,7 +436,9 @@ class FedrampModerateSettings(proto.Message): """ kms_settings = proto.Field( - proto.MESSAGE, number=1, message="Workload.KMSSettings", + proto.MESSAGE, + number=1, + message="Workload.KMSSettings", ) class ResourceSettings(proto.Message): @@ -399,11 +460,19 @@ class ResourceSettings(proto.Message): resource with the specified name. """ - resource_id = proto.Field(proto.STRING, number=1,) + resource_id = proto.Field( + proto.STRING, + number=1, + ) resource_type = proto.Field( - proto.ENUM, number=2, enum="Workload.ResourceInfo.ResourceType", + proto.ENUM, + number=2, + enum="Workload.ResourceInfo.ResourceType", + ) + display_name = proto.Field( + proto.STRING, + number=3, ) - display_name = proto.Field(proto.STRING, number=3,) class SaaEnrollmentResponse(proto.Message): r"""Signed Access Approvals (SAA) enrollment response. @@ -439,15 +508,38 @@ class SetupError(proto.Enum): enum="Workload.SaaEnrollmentResponse.SetupState", ) setup_errors = proto.RepeatedField( - proto.ENUM, number=2, enum="Workload.SaaEnrollmentResponse.SetupError", + proto.ENUM, + number=2, + enum="Workload.SaaEnrollmentResponse.SetupError", ) - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - resources = proto.RepeatedField(proto.MESSAGE, number=3, message=ResourceInfo,) - compliance_regime = proto.Field(proto.ENUM, number=4, enum=ComplianceRegime,) - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - billing_account = proto.Field(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=ResourceInfo, + ) + compliance_regime = proto.Field( + proto.ENUM, + number=4, + enum=ComplianceRegime, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + billing_account = proto.Field( + proto.STRING, + number=6, + ) il4_settings = proto.Field( proto.MESSAGE, number=7, @@ -472,17 +564,42 @@ class SetupError(proto.Enum): oneof="compliance_regime_settings", message=FedrampModerateSettings, ) - etag = proto.Field(proto.STRING, number=9,) - labels = proto.MapField(proto.STRING, proto.STRING, number=10,) - provisioned_resources_parent = proto.Field(proto.STRING, number=13,) - kms_settings = proto.Field(proto.MESSAGE, number=14, message=KMSSettings,) + etag = proto.Field( + proto.STRING, + number=9, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=10, + ) + provisioned_resources_parent = proto.Field( + proto.STRING, + number=13, + ) + kms_settings = proto.Field( + proto.MESSAGE, + number=14, + message=KMSSettings, + ) resource_settings = proto.RepeatedField( - proto.MESSAGE, number=15, message=ResourceSettings, + proto.MESSAGE, + number=15, + message=ResourceSettings, + ) + kaj_enrollment_state = proto.Field( + proto.ENUM, + number=17, + enum=KajEnrollmentState, + ) + enable_sovereign_controls = proto.Field( + proto.BOOL, + number=18, ) - kaj_enrollment_state = proto.Field(proto.ENUM, number=17, enum=KajEnrollmentState,) - enable_sovereign_controls = proto.Field(proto.BOOL, number=18,) saa_enrollment_response = proto.Field( - proto.MESSAGE, number=20, message=SaaEnrollmentResponse, + proto.MESSAGE, + number=20, + message=SaaEnrollmentResponse, ) @@ -507,14 +624,28 @@ class CreateWorkloadOperationMetadata(proto.Message): resources. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - display_name = proto.Field(proto.STRING, number=2,) - parent = proto.Field(proto.STRING, number=3,) + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + parent = proto.Field( + proto.STRING, + number=3, + ) compliance_regime = proto.Field( - proto.ENUM, number=4, enum="Workload.ComplianceRegime", + proto.ENUM, + number=4, + enum="Workload.ComplianceRegime", ) resource_settings = proto.RepeatedField( - proto.MESSAGE, number=5, message="Workload.ResourceSettings", + proto.MESSAGE, + number=5, + message="Workload.ResourceSettings", ) diff --git a/packages/google-cloud-assured-workloads/noxfile.py b/packages/google-cloud-assured-workloads/noxfile.py index 2a2001c49998..3addb4ed9431 100644 --- a/packages/google-cloud-assured-workloads/noxfile.py +++ b/packages/google-cloud-assured-workloads/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/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py index 1d4a71278dba..f68edf77fe9e 100644 --- a/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py +++ b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py @@ -100,7 +100,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [AssuredWorkloadsServiceClient, AssuredWorkloadsServiceAsyncClient,] + "client_class", + [ + AssuredWorkloadsServiceClient, + AssuredWorkloadsServiceAsyncClient, + ], ) def test_assured_workloads_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -142,7 +146,11 @@ def test_assured_workloads_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [AssuredWorkloadsServiceClient, AssuredWorkloadsServiceAsyncClient,] + "client_class", + [ + AssuredWorkloadsServiceClient, + AssuredWorkloadsServiceAsyncClient, + ], ) def test_assured_workloads_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -526,7 +534,9 @@ def test_assured_workloads_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) @@ -667,11 +677,16 @@ def test_assured_workloads_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [assuredworkloads.CreateWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads.CreateWorkloadRequest, + dict, + ], ) def test_create_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -697,7 +712,8 @@ def test_create_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -713,7 +729,8 @@ async def test_create_workload_async( transport: str = "grpc_asyncio", request_type=assuredworkloads.CreateWorkloadRequest ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -765,7 +782,10 @@ def test_create_workload_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 @@ -794,7 +814,10 @@ async def test_create_workload_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_workload_flattened(): @@ -890,11 +913,16 @@ async def test_create_workload_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [assuredworkloads.UpdateWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads.UpdateWorkloadRequest, + dict, + ], ) def test_update_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -940,7 +968,8 @@ def test_update_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -956,7 +985,8 @@ async def test_update_workload_async( transport: str = "grpc_asyncio", request_type=assuredworkloads.UpdateWorkloadRequest ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1028,9 +1058,10 @@ def test_update_workload_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "workload.name=workload.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "workload.name=workload.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1059,9 +1090,10 @@ async def test_update_workload_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "workload.name=workload.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "workload.name=workload.name/value", + ) in kw["metadata"] def test_update_workload_flattened(): @@ -1157,11 +1189,16 @@ async def test_update_workload_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [assuredworkloads.DeleteWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads.DeleteWorkloadRequest, + dict, + ], ) def test_delete_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1187,7 +1224,8 @@ def test_delete_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1203,7 +1241,8 @@ async def test_delete_workload_async( transport: str = "grpc_asyncio", request_type=assuredworkloads.DeleteWorkloadRequest ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1253,7 +1292,10 @@ def test_delete_workload_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 @@ -1280,7 +1322,10 @@ async def test_delete_workload_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_workload_flattened(): @@ -1294,7 +1339,9 @@ def test_delete_workload_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_workload(name="name_value",) + client.delete_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1314,7 +1361,8 @@ def test_delete_workload_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_workload( - assuredworkloads.DeleteWorkloadRequest(), name="name_value", + assuredworkloads.DeleteWorkloadRequest(), + name="name_value", ) @@ -1332,7 +1380,9 @@ async def test_delete_workload_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_workload(name="name_value",) + response = await client.delete_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1353,14 +1403,22 @@ async def test_delete_workload_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_workload( - assuredworkloads.DeleteWorkloadRequest(), name="name_value", + assuredworkloads.DeleteWorkloadRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [assuredworkloads.GetWorkloadRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + assuredworkloads.GetWorkloadRequest, + dict, + ], +) def test_get_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1406,7 +1464,8 @@ def test_get_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1422,7 +1481,8 @@ async def test_get_workload_async( transport: str = "grpc_asyncio", request_type=assuredworkloads.GetWorkloadRequest ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1494,7 +1554,10 @@ def test_get_workload_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 @@ -1523,7 +1586,10 @@ async def test_get_workload_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_workload_flattened(): @@ -1537,7 +1603,9 @@ def test_get_workload_flattened(): call.return_value = assuredworkloads.Workload() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_workload(name="name_value",) + client.get_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1557,7 +1625,8 @@ def test_get_workload_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_workload( - assuredworkloads.GetWorkloadRequest(), name="name_value", + assuredworkloads.GetWorkloadRequest(), + name="name_value", ) @@ -1577,7 +1646,9 @@ async def test_get_workload_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_workload(name="name_value",) + response = await client.get_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1598,14 +1669,22 @@ async def test_get_workload_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_workload( - assuredworkloads.GetWorkloadRequest(), name="name_value", + assuredworkloads.GetWorkloadRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [assuredworkloads.ListWorkloadsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + assuredworkloads.ListWorkloadsRequest, + dict, + ], +) def test_list_workloads(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1634,7 +1713,8 @@ def test_list_workloads_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1650,7 +1730,8 @@ async def test_list_workloads_async( transport: str = "grpc_asyncio", request_type=assuredworkloads.ListWorkloadsRequest ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1705,7 +1786,10 @@ def test_list_workloads_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 @@ -1734,7 +1818,10 @@ async def test_list_workloads_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_workloads_flattened(): @@ -1748,7 +1835,9 @@ def test_list_workloads_flattened(): call.return_value = assuredworkloads.ListWorkloadsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_workloads(parent="parent_value",) + client.list_workloads( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1768,7 +1857,8 @@ def test_list_workloads_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_workloads( - assuredworkloads.ListWorkloadsRequest(), parent="parent_value", + assuredworkloads.ListWorkloadsRequest(), + parent="parent_value", ) @@ -1788,7 +1878,9 @@ async def test_list_workloads_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_workloads(parent="parent_value",) + response = await client.list_workloads( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1809,13 +1901,15 @@ async def test_list_workloads_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_workloads( - assuredworkloads.ListWorkloadsRequest(), parent="parent_value", + assuredworkloads.ListWorkloadsRequest(), + parent="parent_value", ) def test_list_workloads_pager(transport_name: str = "grpc"): client = AssuredWorkloadsServiceClient( - 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. @@ -1831,13 +1925,20 @@ def test_list_workloads_pager(transport_name: str = "grpc"): next_page_token="abc", ), assuredworkloads.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads.Workload(), + ], + next_page_token="ghi", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(), assuredworkloads.Workload(),], + workloads=[ + assuredworkloads.Workload(), + assuredworkloads.Workload(), + ], ), RuntimeError, ) @@ -1857,7 +1958,8 @@ def test_list_workloads_pager(transport_name: str = "grpc"): def test_list_workloads_pages(transport_name: str = "grpc"): client = AssuredWorkloadsServiceClient( - 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. @@ -1873,13 +1975,20 @@ def test_list_workloads_pages(transport_name: str = "grpc"): next_page_token="abc", ), assuredworkloads.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads.Workload(), + ], + next_page_token="ghi", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(), assuredworkloads.Workload(),], + workloads=[ + assuredworkloads.Workload(), + assuredworkloads.Workload(), + ], ), RuntimeError, ) @@ -1909,17 +2018,26 @@ async def test_list_workloads_async_pager(): next_page_token="abc", ), assuredworkloads.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads.Workload(), + ], + next_page_token="ghi", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(), assuredworkloads.Workload(),], + workloads=[ + assuredworkloads.Workload(), + assuredworkloads.Workload(), + ], ), RuntimeError, ) - async_pager = await client.list_workloads(request={},) + async_pager = await client.list_workloads( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1950,13 +2068,20 @@ async def test_list_workloads_async_pages(): next_page_token="abc", ), assuredworkloads.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads.Workload(), + ], + next_page_token="ghi", ), assuredworkloads.ListWorkloadsResponse( - workloads=[assuredworkloads.Workload(), assuredworkloads.Workload(),], + workloads=[ + assuredworkloads.Workload(), + assuredworkloads.Workload(), + ], ), RuntimeError, ) @@ -1974,7 +2099,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - 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. @@ -1995,7 +2121,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2012,7 +2139,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2061,7 +2189,8 @@ def test_transport_grpc_default(): credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.AssuredWorkloadsServiceGrpcTransport, + client.transport, + transports.AssuredWorkloadsServiceGrpcTransport, ) @@ -2116,7 +2245,8 @@ def test_assured_workloads_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssuredWorkloadsServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2278,7 +2408,8 @@ def test_assured_workloads_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssuredWorkloadsServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2290,7 +2421,8 @@ def test_assured_workloads_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssuredWorkloadsServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2399,12 +2531,16 @@ def test_assured_workloads_service_transport_channel_mtls_with_adc(transport_cla def test_assured_workloads_service_grpc_lro_client(): client = AssuredWorkloadsServiceClient( - 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 @@ -2412,12 +2548,16 @@ def test_assured_workloads_service_grpc_lro_client(): def test_assured_workloads_service_grpc_lro_async_client(): client = AssuredWorkloadsServiceAsyncClient( - 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 @@ -2427,8 +2567,12 @@ def test_workload_path(): organization = "squid" location = "clam" workload = "whelk" - expected = "organizations/{organization}/locations/{location}/workloads/{workload}".format( - organization=organization, location=location, workload=workload, + expected = ( + "organizations/{organization}/locations/{location}/workloads/{workload}".format( + organization=organization, + location=location, + workload=workload, + ) ) actual = AssuredWorkloadsServiceClient.workload_path( organization, location, workload @@ -2471,7 +2615,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssuredWorkloadsServiceClient.common_folder_path(folder) assert expected == actual @@ -2489,7 +2635,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssuredWorkloadsServiceClient.common_organization_path(organization) assert expected == actual @@ -2507,7 +2655,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssuredWorkloadsServiceClient.common_project_path(project) assert expected == actual @@ -2527,7 +2677,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssuredWorkloadsServiceClient.common_location_path(project, location) assert expected == actual @@ -2552,7 +2703,8 @@ def test_client_with_default_client_info(): transports.AssuredWorkloadsServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2561,7 +2713,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssuredWorkloadsServiceClient.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) @@ -2569,7 +2722,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssuredWorkloadsServiceAsyncClient( - 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/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py index 7efa765ed9bc..1628fcfdf8d4 100644 --- a/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py +++ b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py @@ -102,7 +102,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [AssuredWorkloadsServiceClient, AssuredWorkloadsServiceAsyncClient,] + "client_class", + [ + AssuredWorkloadsServiceClient, + AssuredWorkloadsServiceAsyncClient, + ], ) def test_assured_workloads_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -144,7 +148,11 @@ def test_assured_workloads_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [AssuredWorkloadsServiceClient, AssuredWorkloadsServiceAsyncClient,] + "client_class", + [ + AssuredWorkloadsServiceClient, + AssuredWorkloadsServiceAsyncClient, + ], ) def test_assured_workloads_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -528,7 +536,9 @@ def test_assured_workloads_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) @@ -669,11 +679,16 @@ def test_assured_workloads_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [assuredworkloads_v1beta1.CreateWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads_v1beta1.CreateWorkloadRequest, + dict, + ], ) def test_create_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - 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 +714,8 @@ def test_create_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -716,7 +732,8 @@ async def test_create_workload_async( request_type=assuredworkloads_v1beta1.CreateWorkloadRequest, ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -768,7 +785,10 @@ def test_create_workload_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 @@ -797,7 +817,10 @@ async def test_create_workload_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_workload_flattened(): @@ -893,11 +916,16 @@ async def test_create_workload_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [assuredworkloads_v1beta1.UpdateWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads_v1beta1.UpdateWorkloadRequest, + dict, + ], ) def test_update_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -951,7 +979,8 @@ def test_update_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -968,7 +997,8 @@ async def test_update_workload_async( request_type=assuredworkloads_v1beta1.UpdateWorkloadRequest, ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1043,9 +1073,10 @@ def test_update_workload_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "workload.name=workload.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "workload.name=workload.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1074,9 +1105,10 @@ async def test_update_workload_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "workload.name=workload.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "workload.name=workload.name/value", + ) in kw["metadata"] def test_update_workload_flattened(): @@ -1172,11 +1204,16 @@ async def test_update_workload_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [assuredworkloads_v1beta1.DeleteWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads_v1beta1.DeleteWorkloadRequest, + dict, + ], ) def test_delete_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1202,7 +1239,8 @@ def test_delete_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1219,7 +1257,8 @@ async def test_delete_workload_async( request_type=assuredworkloads_v1beta1.DeleteWorkloadRequest, ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1269,7 +1308,10 @@ def test_delete_workload_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 @@ -1296,7 +1338,10 @@ async def test_delete_workload_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_workload_flattened(): @@ -1310,7 +1355,9 @@ def test_delete_workload_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_workload(name="name_value",) + client.delete_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1330,7 +1377,8 @@ def test_delete_workload_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_workload( - assuredworkloads_v1beta1.DeleteWorkloadRequest(), name="name_value", + assuredworkloads_v1beta1.DeleteWorkloadRequest(), + name="name_value", ) @@ -1348,7 +1396,9 @@ async def test_delete_workload_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_workload(name="name_value",) + response = await client.delete_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1369,16 +1419,22 @@ async def test_delete_workload_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_workload( - assuredworkloads_v1beta1.DeleteWorkloadRequest(), name="name_value", + assuredworkloads_v1beta1.DeleteWorkloadRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [assuredworkloads_v1beta1.GetWorkloadRequest, dict,] + "request_type", + [ + assuredworkloads_v1beta1.GetWorkloadRequest, + dict, + ], ) def test_get_workload(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1432,7 +1488,8 @@ def test_get_workload_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1449,7 +1506,8 @@ async def test_get_workload_async( request_type=assuredworkloads_v1beta1.GetWorkloadRequest, ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1524,7 +1582,10 @@ def test_get_workload_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 @@ -1553,7 +1614,10 @@ async def test_get_workload_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_workload_flattened(): @@ -1567,7 +1631,9 @@ def test_get_workload_flattened(): call.return_value = assuredworkloads_v1beta1.Workload() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_workload(name="name_value",) + client.get_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1587,7 +1653,8 @@ def test_get_workload_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_workload( - assuredworkloads_v1beta1.GetWorkloadRequest(), name="name_value", + assuredworkloads_v1beta1.GetWorkloadRequest(), + name="name_value", ) @@ -1607,7 +1674,9 @@ async def test_get_workload_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_workload(name="name_value",) + response = await client.get_workload( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1628,16 +1697,22 @@ async def test_get_workload_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_workload( - assuredworkloads_v1beta1.GetWorkloadRequest(), name="name_value", + assuredworkloads_v1beta1.GetWorkloadRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [assuredworkloads_v1beta1.ListWorkloadsRequest, dict,] + "request_type", + [ + assuredworkloads_v1beta1.ListWorkloadsRequest, + dict, + ], ) def test_list_workloads(request_type, transport: str = "grpc"): client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1666,7 +1741,8 @@ def test_list_workloads_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 = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1683,7 +1759,8 @@ async def test_list_workloads_async( request_type=assuredworkloads_v1beta1.ListWorkloadsRequest, ): client = AssuredWorkloadsServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1738,7 +1815,10 @@ def test_list_workloads_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 @@ -1767,7 +1847,10 @@ async def test_list_workloads_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_workloads_flattened(): @@ -1781,7 +1864,9 @@ def test_list_workloads_flattened(): call.return_value = assuredworkloads_v1beta1.ListWorkloadsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_workloads(parent="parent_value",) + client.list_workloads( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1801,7 +1886,8 @@ def test_list_workloads_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_workloads( - assuredworkloads_v1beta1.ListWorkloadsRequest(), parent="parent_value", + assuredworkloads_v1beta1.ListWorkloadsRequest(), + parent="parent_value", ) @@ -1821,7 +1907,9 @@ async def test_list_workloads_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_workloads(parent="parent_value",) + response = await client.list_workloads( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1842,13 +1930,15 @@ async def test_list_workloads_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_workloads( - assuredworkloads_v1beta1.ListWorkloadsRequest(), parent="parent_value", + assuredworkloads_v1beta1.ListWorkloadsRequest(), + parent="parent_value", ) def test_list_workloads_pager(transport_name: str = "grpc"): client = AssuredWorkloadsServiceClient( - 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. @@ -1864,10 +1954,14 @@ def test_list_workloads_pager(transport_name: str = "grpc"): next_page_token="abc", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[assuredworkloads_v1beta1.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads_v1beta1.Workload(), + ], + next_page_token="ghi", ), assuredworkloads_v1beta1.ListWorkloadsResponse( workloads=[ @@ -1893,7 +1987,8 @@ def test_list_workloads_pager(transport_name: str = "grpc"): def test_list_workloads_pages(transport_name: str = "grpc"): client = AssuredWorkloadsServiceClient( - 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. @@ -1909,10 +2004,14 @@ def test_list_workloads_pages(transport_name: str = "grpc"): next_page_token="abc", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[assuredworkloads_v1beta1.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads_v1beta1.Workload(), + ], + next_page_token="ghi", ), assuredworkloads_v1beta1.ListWorkloadsResponse( workloads=[ @@ -1948,10 +2047,14 @@ async def test_list_workloads_async_pager(): next_page_token="abc", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[assuredworkloads_v1beta1.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads_v1beta1.Workload(), + ], + next_page_token="ghi", ), assuredworkloads_v1beta1.ListWorkloadsResponse( workloads=[ @@ -1961,7 +2064,9 @@ async def test_list_workloads_async_pager(): ), RuntimeError, ) - async_pager = await client.list_workloads(request={},) + async_pager = await client.list_workloads( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1992,10 +2097,14 @@ async def test_list_workloads_async_pages(): next_page_token="abc", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[], next_page_token="def", + workloads=[], + next_page_token="def", ), assuredworkloads_v1beta1.ListWorkloadsResponse( - workloads=[assuredworkloads_v1beta1.Workload(),], next_page_token="ghi", + workloads=[ + assuredworkloads_v1beta1.Workload(), + ], + next_page_token="ghi", ), assuredworkloads_v1beta1.ListWorkloadsResponse( workloads=[ @@ -2019,7 +2128,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - 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. @@ -2040,7 +2150,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2057,7 +2168,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AssuredWorkloadsServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2106,7 +2218,8 @@ def test_transport_grpc_default(): credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.AssuredWorkloadsServiceGrpcTransport, + client.transport, + transports.AssuredWorkloadsServiceGrpcTransport, ) @@ -2161,7 +2274,8 @@ def test_assured_workloads_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AssuredWorkloadsServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2323,7 +2437,8 @@ def test_assured_workloads_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AssuredWorkloadsServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2335,7 +2450,8 @@ def test_assured_workloads_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AssuredWorkloadsServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2444,12 +2560,16 @@ def test_assured_workloads_service_transport_channel_mtls_with_adc(transport_cla def test_assured_workloads_service_grpc_lro_client(): client = AssuredWorkloadsServiceClient( - 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 @@ -2457,12 +2577,16 @@ def test_assured_workloads_service_grpc_lro_client(): def test_assured_workloads_service_grpc_lro_async_client(): client = AssuredWorkloadsServiceAsyncClient( - 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 @@ -2472,8 +2596,12 @@ def test_workload_path(): organization = "squid" location = "clam" workload = "whelk" - expected = "organizations/{organization}/locations/{location}/workloads/{workload}".format( - organization=organization, location=location, workload=workload, + expected = ( + "organizations/{organization}/locations/{location}/workloads/{workload}".format( + organization=organization, + location=location, + workload=workload, + ) ) actual = AssuredWorkloadsServiceClient.workload_path( organization, location, workload @@ -2516,7 +2644,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AssuredWorkloadsServiceClient.common_folder_path(folder) assert expected == actual @@ -2534,7 +2664,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AssuredWorkloadsServiceClient.common_organization_path(organization) assert expected == actual @@ -2552,7 +2684,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AssuredWorkloadsServiceClient.common_project_path(project) assert expected == actual @@ -2572,7 +2706,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AssuredWorkloadsServiceClient.common_location_path(project, location) assert expected == actual @@ -2597,7 +2732,8 @@ def test_client_with_default_client_info(): transports.AssuredWorkloadsServiceTransport, "_prep_wrapped_messages" ) as prep: client = AssuredWorkloadsServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2606,7 +2742,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AssuredWorkloadsServiceClient.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) @@ -2614,7 +2751,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AssuredWorkloadsServiceAsyncClient( - 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"