diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 8807627..87dd006 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 4858738..16854da 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-shell", "google-cloud-shell Documentation", [author], 1,) + ( + root_doc, + "google-cloud-shell", + "google-cloud-shell Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/shell_v1/services/cloud_shell_service/async_client.py b/google/cloud/shell_v1/services/cloud_shell_service/async_client.py index 3fddf3b..d126e4b 100644 --- a/google/cloud/shell_v1/services/cloud_shell_service/async_client.py +++ b/google/cloud/shell_v1/services/cloud_shell_service/async_client.py @@ -301,7 +301,8 @@ def sample_get_environment(): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, core_exceptions.Unknown, + core_exceptions.ServiceUnavailable, + core_exceptions.Unknown, ), deadline=60.0, ), @@ -316,7 +317,12 @@ def sample_get_environment(): ) # 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 @@ -398,7 +404,12 @@ def sample_start_environment(): ) # 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( @@ -484,7 +495,12 @@ def sample_authorize_environment(): ) # 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( @@ -571,7 +587,12 @@ def sample_add_public_key(): ) # 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( @@ -658,7 +679,12 @@ def sample_remove_public_key(): ) # 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( @@ -680,7 +706,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-shell",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-shell", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/shell_v1/services/cloud_shell_service/client.py b/google/cloud/shell_v1/services/cloud_shell_service/client.py index 0d28657..85fb173 100644 --- a/google/cloud/shell_v1/services/cloud_shell_service/client.py +++ b/google/cloud/shell_v1/services/cloud_shell_service/client.py @@ -57,7 +57,8 @@ class CloudShellServiceClientMeta(type): _transport_registry["grpc_asyncio"] = CloudShellServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[CloudShellServiceTransport]: """Returns an appropriate transport class. @@ -171,10 +172,14 @@ def transport(self) -> CloudShellServiceTransport: return self._transport @staticmethod - def environment_path(user: str, environment: str,) -> str: + def environment_path( + user: str, + environment: str, + ) -> str: """Returns a fully-qualified environment string.""" return "users/{user}/environments/{environment}".format( - user=user, environment=environment, + user=user, + environment=environment, ) @staticmethod @@ -184,7 +189,9 @@ def parse_environment_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 +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]: @@ -208,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]: @@ -219,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]: @@ -230,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 @@ -501,7 +524,12 @@ def sample_get_environment(): ) # 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 @@ -584,7 +612,12 @@ def sample_start_environment(): ) # 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( @@ -671,7 +704,12 @@ def sample_authorize_environment(): ) # 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( @@ -759,7 +797,12 @@ def sample_add_public_key(): ) # 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( @@ -847,7 +890,12 @@ def sample_remove_public_key(): ) # 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( @@ -876,7 +924,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-shell",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-shell", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py b/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py index 9952e10..b474bcf 100644 --- a/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py +++ b/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py @@ -31,7 +31,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-shell",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-shell", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -127,7 +129,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, core_exceptions.Unknown, + core_exceptions.ServiceUnavailable, + core_exceptions.Unknown, ), deadline=60.0, ), @@ -135,7 +138,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.start_environment: gapic_v1.method.wrap_method( - self.start_environment, default_timeout=60.0, client_info=client_info, + self.start_environment, + default_timeout=60.0, + client_info=client_info, ), self.authorize_environment: gapic_v1.method.wrap_method( self.authorize_environment, @@ -143,19 +148,23 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.add_public_key: gapic_v1.method.wrap_method( - self.add_public_key, default_timeout=60.0, client_info=client_info, + self.add_public_key, + default_timeout=60.0, + client_info=client_info, ), self.remove_public_key: gapic_v1.method.wrap_method( - self.remove_public_key, default_timeout=60.0, client_info=client_info, + self.remove_public_key, + default_timeout=60.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py b/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py index 5a09b82..9ba1ea6 100644 --- a/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py +++ b/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py @@ -234,8 +234,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/shell_v1/types/cloudshell.py b/google/cloud/shell_v1/types/cloudshell.py index 8e6662b..1cbe91f 100644 --- a/google/cloud/shell_v1/types/cloudshell.py +++ b/google/cloud/shell_v1/types/cloudshell.py @@ -101,15 +101,43 @@ class State(proto.Enum): RUNNING = 3 DELETING = 4 - name = proto.Field(proto.STRING, number=1,) - id = proto.Field(proto.STRING, number=2,) - docker_image = proto.Field(proto.STRING, number=3,) - state = proto.Field(proto.ENUM, number=4, enum=State,) - web_host = proto.Field(proto.STRING, number=12,) - ssh_username = proto.Field(proto.STRING, number=5,) - ssh_host = proto.Field(proto.STRING, number=6,) - ssh_port = proto.Field(proto.INT32, number=7,) - public_keys = proto.RepeatedField(proto.STRING, number=8,) + name = proto.Field( + proto.STRING, + number=1, + ) + id = proto.Field( + proto.STRING, + number=2, + ) + docker_image = proto.Field( + proto.STRING, + number=3, + ) + state = proto.Field( + proto.ENUM, + number=4, + enum=State, + ) + web_host = proto.Field( + proto.STRING, + number=12, + ) + ssh_username = proto.Field( + proto.STRING, + number=5, + ) + ssh_host = proto.Field( + proto.STRING, + number=6, + ) + ssh_port = proto.Field( + proto.INT32, + number=7, + ) + public_keys = proto.RepeatedField( + proto.STRING, + number=8, + ) class GetEnvironmentRequest(proto.Message): @@ -123,7 +151,10 @@ class GetEnvironmentRequest(proto.Message): ``users/someone@example.com/environments/default``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class CreateEnvironmentMetadata(proto.Message): @@ -162,9 +193,18 @@ class StartEnvironmentRequest(proto.Message): environment before it is started. """ - name = proto.Field(proto.STRING, number=1,) - access_token = proto.Field(proto.STRING, number=2,) - public_keys = proto.RepeatedField(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + access_token = proto.Field( + proto.STRING, + number=2, + ) + public_keys = proto.RepeatedField( + proto.STRING, + number=3, + ) class AuthorizeEnvironmentRequest(proto.Message): @@ -188,10 +228,23 @@ class AuthorizeEnvironmentRequest(proto.Message): received the request. """ - name = proto.Field(proto.STRING, number=1,) - access_token = proto.Field(proto.STRING, number=2,) - id_token = proto.Field(proto.STRING, number=4,) - expire_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + access_token = proto.Field( + proto.STRING, + number=2, + ) + id_token = proto.Field( + proto.STRING, + number=4, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) class AuthorizeEnvironmentResponse(proto.Message): @@ -231,7 +284,11 @@ class State(proto.Enum): AWAITING_COMPUTE_RESOURCES = 4 FINISHED = 3 - state = proto.Field(proto.ENUM, number=1, enum=State,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) class StartEnvironmentResponse(proto.Message): @@ -244,7 +301,11 @@ class StartEnvironmentResponse(proto.Message): Environment that was started. """ - environment = proto.Field(proto.MESSAGE, number=1, message="Environment",) + environment = proto.Field( + proto.MESSAGE, + number=1, + message="Environment", + ) class AddPublicKeyRequest(proto.Message): @@ -265,8 +326,14 @@ class AddPublicKeyRequest(proto.Message): encoded with Base64. """ - environment = proto.Field(proto.STRING, number=1,) - key = proto.Field(proto.STRING, number=2,) + environment = proto.Field( + proto.STRING, + number=1, + ) + key = proto.Field( + proto.STRING, + number=2, + ) class AddPublicKeyResponse(proto.Message): @@ -278,7 +345,10 @@ class AddPublicKeyResponse(proto.Message): Key that was added to the environment. """ - key = proto.Field(proto.STRING, number=1,) + key = proto.Field( + proto.STRING, + number=1, + ) class AddPublicKeyMetadata(proto.Message): @@ -301,8 +371,14 @@ class RemovePublicKeyRequest(proto.Message): environment. """ - environment = proto.Field(proto.STRING, number=1,) - key = proto.Field(proto.STRING, number=2,) + environment = proto.Field( + proto.STRING, + number=1, + ) + key = proto.Field( + proto.STRING, + number=2, + ) class RemovePublicKeyResponse(proto.Message): @@ -337,7 +413,11 @@ class CloudShellErrorCode(proto.Enum): TOS_VIOLATION = 4 QUOTA_EXCEEDED = 5 - code = proto.Field(proto.ENUM, number=1, enum=CloudShellErrorCode,) + code = proto.Field( + proto.ENUM, + number=1, + enum=CloudShellErrorCode, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..3addb4e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/tests/unit/gapic/shell_v1/test_cloud_shell_service.py b/tests/unit/gapic/shell_v1/test_cloud_shell_service.py index d7f5537..992f939 100644 --- a/tests/unit/gapic/shell_v1/test_cloud_shell_service.py +++ b/tests/unit/gapic/shell_v1/test_cloud_shell_service.py @@ -93,7 +93,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [CloudShellServiceClient, CloudShellServiceAsyncClient,] + "client_class", + [ + CloudShellServiceClient, + CloudShellServiceAsyncClient, + ], ) def test_cloud_shell_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -135,7 +139,11 @@ def test_cloud_shell_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [CloudShellServiceClient, CloudShellServiceAsyncClient,] + "client_class", + [ + CloudShellServiceClient, + CloudShellServiceAsyncClient, + ], ) def test_cloud_shell_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -509,7 +517,9 @@ def test_cloud_shell_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) @@ -649,10 +659,17 @@ def test_cloud_shell_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloudshell.GetEnvironmentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudshell.GetEnvironmentRequest, + dict, + ], +) def test_get_environment(request_type, transport: str = "grpc"): client = CloudShellServiceClient( - 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 +714,8 @@ def test_get_environment_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 = CloudShellServiceClient( - 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 +731,8 @@ async def test_get_environment_async( transport: str = "grpc_asyncio", request_type=cloudshell.GetEnvironmentRequest ): client = CloudShellServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -762,7 +781,9 @@ async def test_get_environment_async_from_dict(): def test_get_environment_field_headers(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -782,7 +803,10 @@ def test_get_environment_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 @@ -811,11 +835,16 @@ async def test_get_environment_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_environment_flattened(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_environment), "__call__") as call: @@ -823,7 +852,9 @@ def test_get_environment_flattened(): call.return_value = cloudshell.Environment() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_environment(name="name_value",) + client.get_environment( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -835,13 +866,16 @@ def test_get_environment_flattened(): def test_get_environment_flattened_error(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_environment( - cloudshell.GetEnvironmentRequest(), name="name_value", + cloudshell.GetEnvironmentRequest(), + name="name_value", ) @@ -861,7 +895,9 @@ async def test_get_environment_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_environment(name="name_value",) + response = await client.get_environment( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -882,14 +918,22 @@ async def test_get_environment_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_environment( - cloudshell.GetEnvironmentRequest(), name="name_value", + cloudshell.GetEnvironmentRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudshell.StartEnvironmentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudshell.StartEnvironmentRequest, + dict, + ], +) def test_start_environment(request_type, transport: str = "grpc"): client = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -917,7 +961,8 @@ def test_start_environment_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 = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -935,7 +980,8 @@ async def test_start_environment_async( transport: str = "grpc_asyncio", request_type=cloudshell.StartEnvironmentRequest ): client = CloudShellServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -967,7 +1013,9 @@ async def test_start_environment_async_from_dict(): def test_start_environment_field_headers(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -989,7 +1037,10 @@ def test_start_environment_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 @@ -1020,15 +1071,23 @@ async def test_start_environment_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"] @pytest.mark.parametrize( - "request_type", [cloudshell.AuthorizeEnvironmentRequest, dict,] + "request_type", + [ + cloudshell.AuthorizeEnvironmentRequest, + dict, + ], ) def test_authorize_environment(request_type, transport: str = "grpc"): client = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1056,7 +1115,8 @@ def test_authorize_environment_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 = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1074,7 +1134,8 @@ async def test_authorize_environment_async( transport: str = "grpc_asyncio", request_type=cloudshell.AuthorizeEnvironmentRequest ): client = CloudShellServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1106,7 +1167,9 @@ async def test_authorize_environment_async_from_dict(): def test_authorize_environment_field_headers(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1128,7 +1191,10 @@ def test_authorize_environment_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 @@ -1159,13 +1225,23 @@ async def test_authorize_environment_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"] -@pytest.mark.parametrize("request_type", [cloudshell.AddPublicKeyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudshell.AddPublicKeyRequest, + dict, + ], +) def test_add_public_key(request_type, transport: str = "grpc"): client = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1191,7 +1267,8 @@ def test_add_public_key_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 = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1207,7 +1284,8 @@ async def test_add_public_key_async( transport: str = "grpc_asyncio", request_type=cloudshell.AddPublicKeyRequest ): client = CloudShellServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1237,7 +1315,9 @@ async def test_add_public_key_async_from_dict(): def test_add_public_key_field_headers(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1257,7 +1337,10 @@ def test_add_public_key_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "environment=environment/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "environment=environment/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1286,13 +1369,23 @@ async def test_add_public_key_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "environment=environment/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "environment=environment/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [cloudshell.RemovePublicKeyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudshell.RemovePublicKeyRequest, + dict, + ], +) def test_remove_public_key(request_type, transport: str = "grpc"): client = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1320,7 +1413,8 @@ def test_remove_public_key_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 = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1338,7 +1432,8 @@ async def test_remove_public_key_async( transport: str = "grpc_asyncio", request_type=cloudshell.RemovePublicKeyRequest ): client = CloudShellServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1370,7 +1465,9 @@ async def test_remove_public_key_async_from_dict(): def test_remove_public_key_field_headers(): - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1392,7 +1489,10 @@ def test_remove_public_key_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "environment=environment/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "environment=environment/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1423,7 +1523,10 @@ async def test_remove_public_key_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "environment=environment/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "environment=environment/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -1433,7 +1536,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudShellServiceClient( - 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. @@ -1453,7 +1557,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudShellServiceClient(client_options=options, transport=transport,) + client = CloudShellServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1469,7 +1576,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudShellServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1514,8 +1622,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudShellServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudShellServiceGrpcTransport,) + client = CloudShellServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudShellServiceGrpcTransport, + ) def test_cloud_shell_service_base_transport_error(): @@ -1569,7 +1682,8 @@ def test_cloud_shell_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudShellServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1729,7 +1843,8 @@ def test_cloud_shell_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudShellServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1741,7 +1856,8 @@ def test_cloud_shell_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudShellServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1850,12 +1966,16 @@ def test_cloud_shell_service_transport_channel_mtls_with_adc(transport_class): def test_cloud_shell_service_grpc_lro_client(): client = CloudShellServiceClient( - 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 @@ -1863,12 +1983,16 @@ def test_cloud_shell_service_grpc_lro_client(): def test_cloud_shell_service_grpc_lro_async_client(): client = CloudShellServiceAsyncClient( - 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 @@ -1878,7 +2002,8 @@ def test_environment_path(): user = "squid" environment = "clam" expected = "users/{user}/environments/{environment}".format( - user=user, environment=environment, + user=user, + environment=environment, ) actual = CloudShellServiceClient.environment_path(user, environment) assert expected == actual @@ -1918,7 +2043,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudShellServiceClient.common_folder_path(folder) assert expected == actual @@ -1936,7 +2063,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudShellServiceClient.common_organization_path(organization) assert expected == actual @@ -1954,7 +2083,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudShellServiceClient.common_project_path(project) assert expected == actual @@ -1974,7 +2105,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudShellServiceClient.common_location_path(project, location) assert expected == actual @@ -1999,7 +2131,8 @@ def test_client_with_default_client_info(): transports.CloudShellServiceTransport, "_prep_wrapped_messages" ) as prep: client = CloudShellServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2008,7 +2141,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudShellServiceClient.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) @@ -2016,7 +2150,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudShellServiceAsyncClient( - 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"