From 3fd21d487df645e7b0ac1efc6a32c8b19ac5fb19 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 25 Aug 2021 13:38:24 +0000 Subject: [PATCH] fix: Remove ActivateSpoke and DeactivateSpoke methods (#69) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 392500501 Source-Link: https://github.com/googleapis/googleapis/commit/d06d94e541c6405a2f12cc35bb60ecc1a7dfdb52 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b368af0aabeac99dfd7c267950a412e2c1eaca11 feat: Add hub.routing_vpcs field docs: Specify that site_to_site_data_transfer field must be set to true --- google/cloud/networkconnectivity/__init__.py | 6 +- .../cloud/networkconnectivity_v1/__init__.py | 6 +- .../gapic_metadata.json | 20 - .../services/hub_service/async_client.py | 185 +------ .../services/hub_service/client.py | 198 +------- .../services/hub_service/transports/base.py | 24 - .../services/hub_service/transports/grpc.py | 57 --- .../hub_service/transports/grpc_asyncio.py | 57 --- .../networkconnectivity_v1/types/__init__.py | 6 +- .../networkconnectivity_v1/types/common.py | 8 +- .../cloud/networkconnectivity_v1/types/hub.py | 132 ++--- .../fixup_networkconnectivity_v1_keywords.py | 2 - .../test_hub_service.py | 458 ++---------------- 13 files changed, 109 insertions(+), 1050 deletions(-) diff --git a/google/cloud/networkconnectivity/__init__.py b/google/cloud/networkconnectivity/__init__.py index efa2753..8576545 100644 --- a/google/cloud/networkconnectivity/__init__.py +++ b/google/cloud/networkconnectivity/__init__.py @@ -22,10 +22,8 @@ ) from google.cloud.networkconnectivity_v1.types.common import OperationMetadata -from google.cloud.networkconnectivity_v1.types.hub import ActivateSpokeRequest from google.cloud.networkconnectivity_v1.types.hub import CreateHubRequest from google.cloud.networkconnectivity_v1.types.hub import CreateSpokeRequest -from google.cloud.networkconnectivity_v1.types.hub import DeactivateSpokeRequest from google.cloud.networkconnectivity_v1.types.hub import DeleteHubRequest from google.cloud.networkconnectivity_v1.types.hub import DeleteSpokeRequest from google.cloud.networkconnectivity_v1.types.hub import GetHubRequest @@ -39,6 +37,7 @@ from google.cloud.networkconnectivity_v1.types.hub import ListSpokesRequest from google.cloud.networkconnectivity_v1.types.hub import ListSpokesResponse from google.cloud.networkconnectivity_v1.types.hub import RouterApplianceInstance +from google.cloud.networkconnectivity_v1.types.hub import RoutingVPC from google.cloud.networkconnectivity_v1.types.hub import Spoke from google.cloud.networkconnectivity_v1.types.hub import UpdateHubRequest from google.cloud.networkconnectivity_v1.types.hub import UpdateSpokeRequest @@ -48,10 +47,8 @@ "HubServiceClient", "HubServiceAsyncClient", "OperationMetadata", - "ActivateSpokeRequest", "CreateHubRequest", "CreateSpokeRequest", - "DeactivateSpokeRequest", "DeleteHubRequest", "DeleteSpokeRequest", "GetHubRequest", @@ -65,6 +62,7 @@ "ListSpokesRequest", "ListSpokesResponse", "RouterApplianceInstance", + "RoutingVPC", "Spoke", "UpdateHubRequest", "UpdateSpokeRequest", diff --git a/google/cloud/networkconnectivity_v1/__init__.py b/google/cloud/networkconnectivity_v1/__init__.py index 5d13503..eb0b105 100644 --- a/google/cloud/networkconnectivity_v1/__init__.py +++ b/google/cloud/networkconnectivity_v1/__init__.py @@ -18,10 +18,8 @@ from .services.hub_service import HubServiceAsyncClient from .types.common import OperationMetadata -from .types.hub import ActivateSpokeRequest from .types.hub import CreateHubRequest from .types.hub import CreateSpokeRequest -from .types.hub import DeactivateSpokeRequest from .types.hub import DeleteHubRequest from .types.hub import DeleteSpokeRequest from .types.hub import GetHubRequest @@ -35,6 +33,7 @@ from .types.hub import ListSpokesRequest from .types.hub import ListSpokesResponse from .types.hub import RouterApplianceInstance +from .types.hub import RoutingVPC from .types.hub import Spoke from .types.hub import UpdateHubRequest from .types.hub import UpdateSpokeRequest @@ -42,10 +41,8 @@ __all__ = ( "HubServiceAsyncClient", - "ActivateSpokeRequest", "CreateHubRequest", "CreateSpokeRequest", - "DeactivateSpokeRequest", "DeleteHubRequest", "DeleteSpokeRequest", "GetHubRequest", @@ -61,6 +58,7 @@ "ListSpokesResponse", "OperationMetadata", "RouterApplianceInstance", + "RoutingVPC", "Spoke", "State", "UpdateHubRequest", diff --git a/google/cloud/networkconnectivity_v1/gapic_metadata.json b/google/cloud/networkconnectivity_v1/gapic_metadata.json index b47970f..11b2166 100644 --- a/google/cloud/networkconnectivity_v1/gapic_metadata.json +++ b/google/cloud/networkconnectivity_v1/gapic_metadata.json @@ -10,11 +10,6 @@ "grpc": { "libraryClient": "HubServiceClient", "rpcs": { - "ActivateSpoke": { - "methods": [ - "activate_spoke" - ] - }, "CreateHub": { "methods": [ "create_hub" @@ -25,11 +20,6 @@ "create_spoke" ] }, - "DeactivateSpoke": { - "methods": [ - "deactivate_spoke" - ] - }, "DeleteHub": { "methods": [ "delete_hub" @@ -75,11 +65,6 @@ "grpc-async": { "libraryClient": "HubServiceAsyncClient", "rpcs": { - "ActivateSpoke": { - "methods": [ - "activate_spoke" - ] - }, "CreateHub": { "methods": [ "create_hub" @@ -90,11 +75,6 @@ "create_spoke" ] }, - "DeactivateSpoke": { - "methods": [ - "deactivate_spoke" - ] - }, "DeleteHub": { "methods": [ "delete_hub" diff --git a/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py b/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py index 3992c8a..4bd61a5 100644 --- a/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py +++ b/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py @@ -62,6 +62,8 @@ class HubServiceAsyncClient: parse_interconnect_attachment_path = staticmethod( HubServiceClient.parse_interconnect_attachment_path ) + network_path = staticmethod(HubServiceClient.network_path) + parse_network_path = staticmethod(HubServiceClient.parse_network_path) spoke_path = staticmethod(HubServiceClient.spoke_path) parse_spoke_path = staticmethod(HubServiceClient.parse_spoke_path) vpn_tunnel_path = staticmethod(HubServiceClient.vpn_tunnel_path) @@ -999,189 +1001,6 @@ async def update_spoke( # Done; return the response. return response - async def deactivate_spoke( - self, - request: hub.DeactivateSpokeRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deactivates the specified spoke. Deactivating keeps - the spoke information for future re-activation, but - disconnects the Google Cloud network from non-Google- - Cloud network. - - Args: - request (:class:`google.cloud.networkconnectivity_v1.types.DeactivateSpokeRequest`): - The request object. The request for - [HubService.DeactivateSpoke][google.cloud.networkconnectivity.v1.HubService.DeactivateSpoke]. - name (:class:`str`): - Required. The name of the spoke to - deactivate. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.networkconnectivity_v1.types.Spoke` A spoke represents a connection between your Google Cloud network resources - and a non-Google-Cloud network. - - When you create a spoke, you associate it with a hub. - You must also identify a value for exactly one of the - following fields: - - - linked_vpn_tunnels - - linked_interconnect_attachments - - linked_router_appliance_instances - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = hub.DeactivateSpokeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.deactivate_spoke, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - hub.Spoke, - metadata_type=common.OperationMetadata, - ) - - # Done; return the response. - return response - - async def activate_spoke( - self, - request: hub.ActivateSpokeRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Activates the specified spoke. Activating reconnects - the Google Cloud network with the non-Google-Cloud - network. - - Args: - request (:class:`google.cloud.networkconnectivity_v1.types.ActivateSpokeRequest`): - The request object. The request for - [HubService.ActivateSpoke][google.cloud.networkconnectivity.v1.HubService.ActivateSpoke]. - name (:class:`str`): - Required. The name of the spoke to - activate. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.networkconnectivity_v1.types.Spoke` A spoke represents a connection between your Google Cloud network resources - and a non-Google-Cloud network. - - When you create a spoke, you associate it with a hub. - You must also identify a value for exactly one of the - following fields: - - - linked_vpn_tunnels - - linked_interconnect_attachments - - linked_router_appliance_instances - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = hub.ActivateSpokeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.activate_spoke, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - hub.Spoke, - metadata_type=common.OperationMetadata, - ) - - # Done; return the response. - return response - async def delete_spoke( self, request: hub.DeleteSpokeRequest = None, diff --git a/google/cloud/networkconnectivity_v1/services/hub_service/client.py b/google/cloud/networkconnectivity_v1/services/hub_service/client.py index e11b84d..6a7f264 100644 --- a/google/cloud/networkconnectivity_v1/services/hub_service/client.py +++ b/google/cloud/networkconnectivity_v1/services/hub_service/client.py @@ -213,6 +213,21 @@ def parse_interconnect_attachment_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def network_path(project: str, resource_id: str,) -> str: + """Returns a fully-qualified network string.""" + return "projects/{project}/global/networks/{resource_id}".format( + project=project, resource_id=resource_id, + ) + + @staticmethod + def parse_network_path(path: str) -> Dict[str, str]: + """Parses a network path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/global/networks/(?P.+?)$", path + ) + return m.groupdict() if m else {} + @staticmethod def spoke_path(project: str, location: str, spoke: str,) -> str: """Returns a fully-qualified spoke string.""" @@ -1245,189 +1260,6 @@ def update_spoke( # Done; return the response. return response - def deactivate_spoke( - self, - request: hub.DeactivateSpokeRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deactivates the specified spoke. Deactivating keeps - the spoke information for future re-activation, but - disconnects the Google Cloud network from non-Google- - Cloud network. - - Args: - request (google.cloud.networkconnectivity_v1.types.DeactivateSpokeRequest): - The request object. The request for - [HubService.DeactivateSpoke][google.cloud.networkconnectivity.v1.HubService.DeactivateSpoke]. - name (str): - Required. The name of the spoke to - deactivate. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.networkconnectivity_v1.types.Spoke` A spoke represents a connection between your Google Cloud network resources - and a non-Google-Cloud network. - - When you create a spoke, you associate it with a hub. - You must also identify a value for exactly one of the - following fields: - - - linked_vpn_tunnels - - linked_interconnect_attachments - - linked_router_appliance_instances - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a hub.DeactivateSpokeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, hub.DeactivateSpokeRequest): - request = hub.DeactivateSpokeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.deactivate_spoke] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - hub.Spoke, - metadata_type=common.OperationMetadata, - ) - - # Done; return the response. - return response - - def activate_spoke( - self, - request: hub.ActivateSpokeRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Activates the specified spoke. Activating reconnects - the Google Cloud network with the non-Google-Cloud - network. - - Args: - request (google.cloud.networkconnectivity_v1.types.ActivateSpokeRequest): - The request object. The request for - [HubService.ActivateSpoke][google.cloud.networkconnectivity.v1.HubService.ActivateSpoke]. - name (str): - Required. The name of the spoke to - activate. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.networkconnectivity_v1.types.Spoke` A spoke represents a connection between your Google Cloud network resources - and a non-Google-Cloud network. - - When you create a spoke, you associate it with a hub. - You must also identify a value for exactly one of the - following fields: - - - linked_vpn_tunnels - - linked_interconnect_attachments - - linked_router_appliance_instances - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a hub.ActivateSpokeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, hub.ActivateSpokeRequest): - request = hub.ActivateSpokeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.activate_spoke] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - hub.Spoke, - metadata_type=common.OperationMetadata, - ) - - # Done; return the response. - return response - def delete_spoke( self, request: hub.DeleteSpokeRequest = None, diff --git a/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py b/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py index e885b3c..47d8b5a 100644 --- a/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py +++ b/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py @@ -184,12 +184,6 @@ def _prep_wrapped_messages(self, client_info): self.update_spoke: gapic_v1.method.wrap_method( self.update_spoke, default_timeout=60.0, client_info=client_info, ), - self.deactivate_spoke: gapic_v1.method.wrap_method( - self.deactivate_spoke, default_timeout=60.0, client_info=client_info, - ), - self.activate_spoke: gapic_v1.method.wrap_method( - self.activate_spoke, default_timeout=60.0, client_info=client_info, - ), self.delete_spoke: gapic_v1.method.wrap_method( self.delete_spoke, default_timeout=60.0, client_info=client_info, ), @@ -275,24 +269,6 @@ def update_spoke( ]: raise NotImplementedError() - @property - def deactivate_spoke( - self, - ) -> Callable[ - [hub.DeactivateSpokeRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def activate_spoke( - self, - ) -> Callable[ - [hub.ActivateSpokeRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - @property def delete_spoke( self, diff --git a/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py b/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py index 3b9b38e..6f44d71 100644 --- a/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py +++ b/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py @@ -473,63 +473,6 @@ def update_spoke( ) return self._stubs["update_spoke"] - @property - def deactivate_spoke( - self, - ) -> Callable[[hub.DeactivateSpokeRequest], operations_pb2.Operation]: - r"""Return a callable for the deactivate spoke method over gRPC. - - Deactivates the specified spoke. Deactivating keeps - the spoke information for future re-activation, but - disconnects the Google Cloud network from non-Google- - Cloud network. - - Returns: - Callable[[~.DeactivateSpokeRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "deactivate_spoke" not in self._stubs: - self._stubs["deactivate_spoke"] = self.grpc_channel.unary_unary( - "/google.cloud.networkconnectivity.v1.HubService/DeactivateSpoke", - request_serializer=hub.DeactivateSpokeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["deactivate_spoke"] - - @property - def activate_spoke( - self, - ) -> Callable[[hub.ActivateSpokeRequest], operations_pb2.Operation]: - r"""Return a callable for the activate spoke method over gRPC. - - Activates the specified spoke. Activating reconnects - the Google Cloud network with the non-Google-Cloud - network. - - Returns: - Callable[[~.ActivateSpokeRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "activate_spoke" not in self._stubs: - self._stubs["activate_spoke"] = self.grpc_channel.unary_unary( - "/google.cloud.networkconnectivity.v1.HubService/ActivateSpoke", - request_serializer=hub.ActivateSpokeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["activate_spoke"] - @property def delete_spoke( self, diff --git a/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py b/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py index fbb6d90..52846b5 100644 --- a/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py +++ b/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py @@ -484,63 +484,6 @@ def update_spoke( ) return self._stubs["update_spoke"] - @property - def deactivate_spoke( - self, - ) -> Callable[[hub.DeactivateSpokeRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the deactivate spoke method over gRPC. - - Deactivates the specified spoke. Deactivating keeps - the spoke information for future re-activation, but - disconnects the Google Cloud network from non-Google- - Cloud network. - - Returns: - Callable[[~.DeactivateSpokeRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "deactivate_spoke" not in self._stubs: - self._stubs["deactivate_spoke"] = self.grpc_channel.unary_unary( - "/google.cloud.networkconnectivity.v1.HubService/DeactivateSpoke", - request_serializer=hub.DeactivateSpokeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["deactivate_spoke"] - - @property - def activate_spoke( - self, - ) -> Callable[[hub.ActivateSpokeRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the activate spoke method over gRPC. - - Activates the specified spoke. Activating reconnects - the Google Cloud network with the non-Google-Cloud - network. - - Returns: - Callable[[~.ActivateSpokeRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "activate_spoke" not in self._stubs: - self._stubs["activate_spoke"] = self.grpc_channel.unary_unary( - "/google.cloud.networkconnectivity.v1.HubService/ActivateSpoke", - request_serializer=hub.ActivateSpokeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["activate_spoke"] - @property def delete_spoke( self, diff --git a/google/cloud/networkconnectivity_v1/types/__init__.py b/google/cloud/networkconnectivity_v1/types/__init__.py index 8d56928..15a574d 100644 --- a/google/cloud/networkconnectivity_v1/types/__init__.py +++ b/google/cloud/networkconnectivity_v1/types/__init__.py @@ -15,10 +15,8 @@ # from .common import OperationMetadata from .hub import ( - ActivateSpokeRequest, CreateHubRequest, CreateSpokeRequest, - DeactivateSpokeRequest, DeleteHubRequest, DeleteSpokeRequest, GetHubRequest, @@ -32,6 +30,7 @@ ListSpokesRequest, ListSpokesResponse, RouterApplianceInstance, + RoutingVPC, Spoke, UpdateHubRequest, UpdateSpokeRequest, @@ -40,10 +39,8 @@ __all__ = ( "OperationMetadata", - "ActivateSpokeRequest", "CreateHubRequest", "CreateSpokeRequest", - "DeactivateSpokeRequest", "DeleteHubRequest", "DeleteSpokeRequest", "GetHubRequest", @@ -57,6 +54,7 @@ "ListSpokesRequest", "ListSpokesResponse", "RouterApplianceInstance", + "RoutingVPC", "Spoke", "UpdateHubRequest", "UpdateSpokeRequest", diff --git a/google/cloud/networkconnectivity_v1/types/common.py b/google/cloud/networkconnectivity_v1/types/common.py index d839533..ab5c56e 100644 --- a/google/cloud/networkconnectivity_v1/types/common.py +++ b/google/cloud/networkconnectivity_v1/types/common.py @@ -43,10 +43,10 @@ class OperationMetadata(proto.Message): operation, if any. requested_cancellation (bool): Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. + cancellation of the operation. Operations that have been + cancelled successfully have [Operation.error][] value with a + [google.rpc.Status.code][google.rpc.Status.code] of 1, + corresponding to ``Code.CANCELLED``. api_version (str): Output only. API version used to start the operation. diff --git a/google/cloud/networkconnectivity_v1/types/hub.py b/google/cloud/networkconnectivity_v1/types/hub.py index 66334e9..98c0e47 100644 --- a/google/cloud/networkconnectivity_v1/types/hub.py +++ b/google/cloud/networkconnectivity_v1/types/hub.py @@ -24,6 +24,7 @@ manifest={ "State", "Hub", + "RoutingVPC", "Spoke", "ListHubsRequest", "ListHubsResponse", @@ -37,8 +38,6 @@ "CreateSpokeRequest", "UpdateSpokeRequest", "DeleteSpokeRequest", - "DeactivateSpokeRequest", - "ActivateSpokeRequest", "LinkedVpnTunnels", "LinkedInterconnectAttachments", "LinkedRouterApplianceInstances", @@ -87,6 +86,16 @@ class Hub(proto.Message): state (google.cloud.networkconnectivity_v1.types.State): Output only. The current lifecycle state of this hub. + routing_vpcs (Sequence[google.cloud.networkconnectivity_v1.types.RoutingVPC]): + The VPC network associated with this hub's + spokes. All of the VPN tunnels, VLAN + attachments, and router appliance instances + referenced by this hub's spokes must belong to + this VPC network. + + This field is read-only. Network Connectivity + Center automatically populates it based on the + set of spokes attached to the hub. """ name = proto.Field(proto.STRING, number=1,) @@ -96,6 +105,19 @@ class Hub(proto.Message): description = proto.Field(proto.STRING, number=5,) unique_id = proto.Field(proto.STRING, number=8,) state = proto.Field(proto.ENUM, number=9, enum="State",) + routing_vpcs = proto.RepeatedField(proto.MESSAGE, number=10, message="RoutingVPC",) + + +class RoutingVPC(proto.Message): + r"""RoutingsVPC contains information about a VPC network that is + associated with a hub's spokes. + + Attributes: + uri (str): + The URI of a VPC network. + """ + + uri = proto.Field(proto.STRING, number=1,) class Spoke(proto.Message): @@ -529,73 +551,6 @@ class DeleteSpokeRequest(proto.Message): request_id = proto.Field(proto.STRING, number=2,) -class DeactivateSpokeRequest(proto.Message): - r"""The request for - [HubService.DeactivateSpoke][google.cloud.networkconnectivity.v1.HubService.DeactivateSpoke]. - - Attributes: - name (str): - Required. The name of the spoke to - deactivate. - request_id (str): - Optional. A unique request ID (optional). If - you specify this ID, you can use it in cases - when you need to retry your request. When you - need to retry, this ID lets the server know that - it can ignore the request if it has already been - completed. The server guarantees that for at - least 60 minutes after the first request. - - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check to see whether the - original operation was received. If it was, the - server ignores the second request. This behavior - prevents clients from mistakenly creating - duplicate commitments. - The request ID must be a valid UUID, with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - request_id = proto.Field(proto.STRING, number=2,) - - -class ActivateSpokeRequest(proto.Message): - r"""The request for - [HubService.ActivateSpoke][google.cloud.networkconnectivity.v1.HubService.ActivateSpoke]. - - Attributes: - name (str): - Required. The name of the spoke to activate. - request_id (str): - Optional. A unique request ID (optional). If - you specify this ID, you can use it in cases - when you need to retry your request. When you - need to retry, this ID lets the server know that - it can ignore the request if it has already been - completed. The server guarantees that for at - least 60 minutes after the first request. - - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check to see whether the - original operation was received. If it was, the - server ignores the second request. This behavior - prevents clients from mistakenly creating - duplicate commitments. - The request ID must be a valid UUID, with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - request_id = proto.Field(proto.STRING, number=2,) - - class LinkedVpnTunnels(proto.Message): r"""A collection of Cloud VPN tunnel resources. These resources should be redundant HA VPN tunnels that all advertise the same @@ -608,15 +563,10 @@ class LinkedVpnTunnels(proto.Message): The URIs of linked VPN tunnel resources. site_to_site_data_transfer (bool): A value that controls whether site-to-site - data transfer is enabled for these resources. If - true, routes are propagated between the spoke - associated with these resources and other spokes - in the hub that have data transfer enabled. If - false, the spoke associated with these resources - provides connectivity only between the external - site and Google Cloud. In regions where data - transfer is unsupported, you cannot set this - field to true. + data transfer is enabled for these resources. + This field is set to false by default, but you + must set it to true. Note that data transfer is + available only in supported locations. """ uris = proto.RepeatedField(proto.STRING, number=1,) @@ -636,15 +586,10 @@ class LinkedInterconnectAttachments(proto.Message): resources site_to_site_data_transfer (bool): A value that controls whether site-to-site - data transfer is enabled for these resources. If - true, routes are propagated between the spoke - associated with these resources and other spokes - in the hub that have data transfer enabled. If - false, the spoke associated with these resources - provides connectivity only between the external - site and Google Cloud. In regions where data - transfer is unsupported, you cannot set this - field to true. + data transfer is enabled for these resources. + This field is set to false by default, but you + must set it to true. Note that data transfer is + available only in supported locations. """ uris = proto.RepeatedField(proto.STRING, number=1,) @@ -661,15 +606,10 @@ class LinkedRouterApplianceInstances(proto.Message): The list of router appliance instances. site_to_site_data_transfer (bool): A value that controls whether site-to-site - data transfer is enabled for these resources. If - true, routes are propagated between the spoke - associated with these resources and other spokes - in the hub that have data transfer enabled. If - false, the spoke associated with these resources - provides connectivity only between the external - site and Google Cloud. In regions where data - transfer is unsupported, you cannot set this - field to true. + data transfer is enabled for these resources. + This field is set to false by default, but you + must set it to true. Note that data transfer is + available only in supported locations. """ instances = proto.RepeatedField( diff --git a/scripts/fixup_networkconnectivity_v1_keywords.py b/scripts/fixup_networkconnectivity_v1_keywords.py index 786f368..2c61070 100644 --- a/scripts/fixup_networkconnectivity_v1_keywords.py +++ b/scripts/fixup_networkconnectivity_v1_keywords.py @@ -39,10 +39,8 @@ def partition( class networkconnectivityCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_spoke': ('name', 'request_id', ), 'create_hub': ('parent', 'hub', 'hub_id', 'request_id', ), 'create_spoke': ('parent', 'spoke', 'spoke_id', 'request_id', ), - 'deactivate_spoke': ('name', 'request_id', ), 'delete_hub': ('name', 'request_id', ), 'delete_spoke': ('name', 'request_id', ), 'get_hub': ('name', ), diff --git a/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py b/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py index 9027e08..9d00d06 100644 --- a/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py +++ b/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py @@ -2533,392 +2533,6 @@ async def test_update_spoke_flattened_error_async(): ) -def test_deactivate_spoke( - transport: str = "grpc", request_type=hub.DeactivateSpokeRequest -): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.deactivate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == hub.DeactivateSpokeRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_deactivate_spoke_from_dict(): - test_deactivate_spoke(request_type=dict) - - -def test_deactivate_spoke_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 = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - client.deactivate_spoke() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == hub.DeactivateSpokeRequest() - - -@pytest.mark.asyncio -async def test_deactivate_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.DeactivateSpokeRequest -): - client = HubServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.deactivate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == hub.DeactivateSpokeRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_deactivate_spoke_async_from_dict(): - await test_deactivate_spoke_async(request_type=dict) - - -def test_deactivate_spoke_field_headers(): - client = HubServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = hub.DeactivateSpokeRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.deactivate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_deactivate_spoke_field_headers_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = hub.DeactivateSpokeRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.deactivate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] - - -def test_deactivate_spoke_flattened(): - client = HubServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.deactivate_spoke(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_deactivate_spoke_flattened_error(): - client = HubServiceClient(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.deactivate_spoke( - hub.DeactivateSpokeRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_deactivate_spoke_flattened_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.deactivate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.deactivate_spoke(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_deactivate_spoke_flattened_error_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.deactivate_spoke( - hub.DeactivateSpokeRequest(), name="name_value", - ) - - -def test_activate_spoke(transport: str = "grpc", request_type=hub.ActivateSpokeRequest): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.activate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == hub.ActivateSpokeRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_activate_spoke_from_dict(): - test_activate_spoke(request_type=dict) - - -def test_activate_spoke_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 = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - client.activate_spoke() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == hub.ActivateSpokeRequest() - - -@pytest.mark.asyncio -async def test_activate_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.ActivateSpokeRequest -): - client = HubServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.activate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == hub.ActivateSpokeRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_activate_spoke_async_from_dict(): - await test_activate_spoke_async(request_type=dict) - - -def test_activate_spoke_field_headers(): - client = HubServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = hub.ActivateSpokeRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.activate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_activate_spoke_field_headers_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = hub.ActivateSpokeRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.activate_spoke(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] - - -def test_activate_spoke_flattened(): - client = HubServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.activate_spoke(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_activate_spoke_flattened_error(): - client = HubServiceClient(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.activate_spoke( - hub.ActivateSpokeRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_activate_spoke_flattened_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.activate_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.activate_spoke(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_activate_spoke_flattened_error_async(): - client = HubServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.activate_spoke( - hub.ActivateSpokeRequest(), name="name_value", - ) - - def test_delete_spoke(transport: str = "grpc", request_type=hub.DeleteSpokeRequest): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3214,8 +2828,6 @@ def test_hub_service_base_transport(): "get_spoke", "create_spoke", "update_spoke", - "deactivate_spoke", - "activate_spoke", "delete_spoke", ) for method in methods: @@ -3649,10 +3261,32 @@ def test_parse_interconnect_attachment_path(): assert expected == actual -def test_spoke_path(): +def test_network_path(): project = "oyster" - location = "nudibranch" - spoke = "cuttlefish" + resource_id = "nudibranch" + expected = "projects/{project}/global/networks/{resource_id}".format( + project=project, resource_id=resource_id, + ) + actual = HubServiceClient.network_path(project, resource_id) + assert expected == actual + + +def test_parse_network_path(): + expected = { + "project": "cuttlefish", + "resource_id": "mussel", + } + path = HubServiceClient.network_path(**expected) + + # Check that the path construction is reversible. + actual = HubServiceClient.parse_network_path(path) + assert expected == actual + + +def test_spoke_path(): + project = "winkle" + location = "nautilus" + spoke = "scallop" expected = "projects/{project}/locations/{location}/spokes/{spoke}".format( project=project, location=location, spoke=spoke, ) @@ -3662,9 +3296,9 @@ def test_spoke_path(): def test_parse_spoke_path(): expected = { - "project": "mussel", - "location": "winkle", - "spoke": "nautilus", + "project": "abalone", + "location": "squid", + "spoke": "clam", } path = HubServiceClient.spoke_path(**expected) @@ -3674,9 +3308,9 @@ def test_parse_spoke_path(): def test_vpn_tunnel_path(): - project = "scallop" - region = "abalone" - resource_id = "squid" + project = "whelk" + region = "octopus" + resource_id = "oyster" expected = "projects/{project}/regions/{region}/vpnTunnels/{resource_id}".format( project=project, region=region, resource_id=resource_id, ) @@ -3686,9 +3320,9 @@ def test_vpn_tunnel_path(): def test_parse_vpn_tunnel_path(): expected = { - "project": "clam", - "region": "whelk", - "resource_id": "octopus", + "project": "nudibranch", + "region": "cuttlefish", + "resource_id": "mussel", } path = HubServiceClient.vpn_tunnel_path(**expected) @@ -3698,7 +3332,7 @@ def test_parse_vpn_tunnel_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "winkle" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3708,7 +3342,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "nautilus", } path = HubServiceClient.common_billing_account_path(**expected) @@ -3718,7 +3352,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "scallop" expected = "folders/{folder}".format(folder=folder,) actual = HubServiceClient.common_folder_path(folder) assert expected == actual @@ -3726,7 +3360,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "abalone", } path = HubServiceClient.common_folder_path(**expected) @@ -3736,7 +3370,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "squid" expected = "organizations/{organization}".format(organization=organization,) actual = HubServiceClient.common_organization_path(organization) assert expected == actual @@ -3744,7 +3378,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "clam", } path = HubServiceClient.common_organization_path(**expected) @@ -3754,7 +3388,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "whelk" expected = "projects/{project}".format(project=project,) actual = HubServiceClient.common_project_path(project) assert expected == actual @@ -3762,7 +3396,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "octopus", } path = HubServiceClient.common_project_path(**expected) @@ -3772,8 +3406,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3783,8 +3417,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "cuttlefish", + "location": "mussel", } path = HubServiceClient.common_location_path(**expected)