From 65b5f5d5e4aa962c056b4824fbeb1bf0c6980302 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 12:20:11 +0000 Subject: [PATCH] feat: add the TunnelDestGroup-related methods and types (#93) - [ ] Regenerate this pull request now. feat: add ReauthSettings to the UpdateIapSettingsRequest PiperOrigin-RevId: 448510642 Source-Link: https://github.com/googleapis/googleapis/commit/dd6f8dfcb01c2dae1a4321aea28e206809647a58 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f94b4742c286a4e40c9f8c9c4c6071eea5d959da Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjk0YjQ3NDJjMjg2YTRlNDBjOWY4YzljNGM2MDcxZWVhNWQ5NTlkYSJ9 --- .../identity_aware_proxy_admin_service.rst | 4 + .../google/cloud/iap/__init__.py | 16 + .../google/cloud/iap_v1/__init__.py | 16 + .../google/cloud/iap_v1/gapic_metadata.json | 50 + .../async_client.py | 535 ++++++ .../client.py | 564 ++++++ .../pagers.py | 155 ++ .../transports/base.py | 74 + .../transports/grpc.py | 135 ++ .../transports/grpc_asyncio.py | 142 ++ .../async_client.py | 14 +- .../client.py | 14 +- .../transports/grpc.py | 14 +- .../transports/grpc_asyncio.py | 14 +- .../google/cloud/iap_v1/types/__init__.py | 16 + .../google/cloud/iap_v1/types/service.py | 251 +++ ..._service_create_tunnel_dest_group_async.py | 50 + ...n_service_create_tunnel_dest_group_sync.py | 50 + ..._service_delete_tunnel_dest_group_async.py | 43 + ...n_service_delete_tunnel_dest_group_sync.py | 43 + ...min_service_get_tunnel_dest_group_async.py | 45 + ...dmin_service_get_tunnel_dest_group_sync.py | 45 + ...n_service_list_tunnel_dest_groups_async.py | 46 + ...in_service_list_tunnel_dest_groups_sync.py | 46 + ..._service_update_tunnel_dest_group_async.py | 48 + ...n_service_update_tunnel_dest_group_sync.py | 48 + .../snippet_metadata_iap_v1.json | 953 +++++++++- .../scripts/fixup_iap_v1_keywords.py | 5 + ...test_identity_aware_proxy_admin_service.py | 1552 ++++++++++++++++- 29 files changed, 4883 insertions(+), 105 deletions(-) create mode 100644 packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py create mode 100644 packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py diff --git a/packages/google-cloud-iap/docs/iap_v1/identity_aware_proxy_admin_service.rst b/packages/google-cloud-iap/docs/iap_v1/identity_aware_proxy_admin_service.rst index 1275baf0189c..3098cf5d3834 100644 --- a/packages/google-cloud-iap/docs/iap_v1/identity_aware_proxy_admin_service.rst +++ b/packages/google-cloud-iap/docs/iap_v1/identity_aware_proxy_admin_service.rst @@ -4,3 +4,7 @@ IdentityAwareProxyAdminService .. automodule:: google.cloud.iap_v1.services.identity_aware_proxy_admin_service :members: :inherited-members: + +.. automodule:: google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers + :members: + :inherited-members: diff --git a/packages/google-cloud-iap/google/cloud/iap/__init__.py b/packages/google-cloud-iap/google/cloud/iap/__init__.py index 1d635e6b463c..77b97467fb0f 100644 --- a/packages/google-cloud-iap/google/cloud/iap/__init__.py +++ b/packages/google-cloud-iap/google/cloud/iap/__init__.py @@ -34,21 +34,29 @@ CorsSettings, CreateBrandRequest, CreateIdentityAwareProxyClientRequest, + CreateTunnelDestGroupRequest, CsmSettings, DeleteIdentityAwareProxyClientRequest, + DeleteTunnelDestGroupRequest, GcipSettings, GetBrandRequest, GetIapSettingsRequest, GetIdentityAwareProxyClientRequest, + GetTunnelDestGroupRequest, IapSettings, IdentityAwareProxyClient, ListBrandsRequest, ListBrandsResponse, ListIdentityAwareProxyClientsRequest, ListIdentityAwareProxyClientsResponse, + ListTunnelDestGroupsRequest, + ListTunnelDestGroupsResponse, OAuthSettings, + ReauthSettings, ResetIdentityAwareProxyClientSecretRequest, + TunnelDestGroup, UpdateIapSettingsRequest, + UpdateTunnelDestGroupRequest, ) __all__ = ( @@ -63,19 +71,27 @@ "CorsSettings", "CreateBrandRequest", "CreateIdentityAwareProxyClientRequest", + "CreateTunnelDestGroupRequest", "CsmSettings", "DeleteIdentityAwareProxyClientRequest", + "DeleteTunnelDestGroupRequest", "GcipSettings", "GetBrandRequest", "GetIapSettingsRequest", "GetIdentityAwareProxyClientRequest", + "GetTunnelDestGroupRequest", "IapSettings", "IdentityAwareProxyClient", "ListBrandsRequest", "ListBrandsResponse", "ListIdentityAwareProxyClientsRequest", "ListIdentityAwareProxyClientsResponse", + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", "OAuthSettings", + "ReauthSettings", "ResetIdentityAwareProxyClientSecretRequest", + "TunnelDestGroup", "UpdateIapSettingsRequest", + "UpdateTunnelDestGroupRequest", ) diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/__init__.py b/packages/google-cloud-iap/google/cloud/iap_v1/__init__.py index ff4ec66fdbb6..487d61792cf3 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/__init__.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/__init__.py @@ -30,21 +30,29 @@ CorsSettings, CreateBrandRequest, CreateIdentityAwareProxyClientRequest, + CreateTunnelDestGroupRequest, CsmSettings, DeleteIdentityAwareProxyClientRequest, + DeleteTunnelDestGroupRequest, GcipSettings, GetBrandRequest, GetIapSettingsRequest, GetIdentityAwareProxyClientRequest, + GetTunnelDestGroupRequest, IapSettings, IdentityAwareProxyClient, ListBrandsRequest, ListBrandsResponse, ListIdentityAwareProxyClientsRequest, ListIdentityAwareProxyClientsResponse, + ListTunnelDestGroupsRequest, + ListTunnelDestGroupsResponse, OAuthSettings, + ReauthSettings, ResetIdentityAwareProxyClientSecretRequest, + TunnelDestGroup, UpdateIapSettingsRequest, + UpdateTunnelDestGroupRequest, ) __all__ = ( @@ -57,12 +65,15 @@ "CorsSettings", "CreateBrandRequest", "CreateIdentityAwareProxyClientRequest", + "CreateTunnelDestGroupRequest", "CsmSettings", "DeleteIdentityAwareProxyClientRequest", + "DeleteTunnelDestGroupRequest", "GcipSettings", "GetBrandRequest", "GetIapSettingsRequest", "GetIdentityAwareProxyClientRequest", + "GetTunnelDestGroupRequest", "IapSettings", "IdentityAwareProxyAdminServiceClient", "IdentityAwareProxyClient", @@ -71,7 +82,12 @@ "ListBrandsResponse", "ListIdentityAwareProxyClientsRequest", "ListIdentityAwareProxyClientsResponse", + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", "OAuthSettings", + "ReauthSettings", "ResetIdentityAwareProxyClientSecretRequest", + "TunnelDestGroup", "UpdateIapSettingsRequest", + "UpdateTunnelDestGroupRequest", ) diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/gapic_metadata.json b/packages/google-cloud-iap/google/cloud/iap_v1/gapic_metadata.json index 8eb05c41b1df..9f855f6318e2 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/gapic_metadata.json +++ b/packages/google-cloud-iap/google/cloud/iap_v1/gapic_metadata.json @@ -10,6 +10,16 @@ "grpc": { "libraryClient": "IdentityAwareProxyAdminServiceClient", "rpcs": { + "CreateTunnelDestGroup": { + "methods": [ + "create_tunnel_dest_group" + ] + }, + "DeleteTunnelDestGroup": { + "methods": [ + "delete_tunnel_dest_group" + ] + }, "GetIamPolicy": { "methods": [ "get_iam_policy" @@ -20,6 +30,16 @@ "get_iap_settings" ] }, + "GetTunnelDestGroup": { + "methods": [ + "get_tunnel_dest_group" + ] + }, + "ListTunnelDestGroups": { + "methods": [ + "list_tunnel_dest_groups" + ] + }, "SetIamPolicy": { "methods": [ "set_iam_policy" @@ -34,12 +54,27 @@ "methods": [ "update_iap_settings" ] + }, + "UpdateTunnelDestGroup": { + "methods": [ + "update_tunnel_dest_group" + ] } } }, "grpc-async": { "libraryClient": "IdentityAwareProxyAdminServiceAsyncClient", "rpcs": { + "CreateTunnelDestGroup": { + "methods": [ + "create_tunnel_dest_group" + ] + }, + "DeleteTunnelDestGroup": { + "methods": [ + "delete_tunnel_dest_group" + ] + }, "GetIamPolicy": { "methods": [ "get_iam_policy" @@ -50,6 +85,16 @@ "get_iap_settings" ] }, + "GetTunnelDestGroup": { + "methods": [ + "get_tunnel_dest_group" + ] + }, + "ListTunnelDestGroups": { + "methods": [ + "list_tunnel_dest_groups" + ] + }, "SetIamPolicy": { "methods": [ "set_iam_policy" @@ -64,6 +109,11 @@ "methods": [ "update_iap_settings" ] + }, + "UpdateTunnelDestGroup": { + "methods": [ + "update_tunnel_dest_group" + ] } } } diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py index 4d97416a3d9e..0c6fed328616 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py @@ -33,7 +33,9 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import pagers from google.cloud.iap_v1.types import service from .client import IdentityAwareProxyAdminServiceClient @@ -52,6 +54,18 @@ class IdentityAwareProxyAdminServiceAsyncClient: DEFAULT_ENDPOINT = IdentityAwareProxyAdminServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = IdentityAwareProxyAdminServiceClient.DEFAULT_MTLS_ENDPOINT + tunnel_dest_group_path = staticmethod( + IdentityAwareProxyAdminServiceClient.tunnel_dest_group_path + ) + parse_tunnel_dest_group_path = staticmethod( + IdentityAwareProxyAdminServiceClient.parse_tunnel_dest_group_path + ) + tunnel_location_path = staticmethod( + IdentityAwareProxyAdminServiceClient.tunnel_location_path + ) + parse_tunnel_location_path = staticmethod( + IdentityAwareProxyAdminServiceClient.parse_tunnel_location_path + ) common_billing_account_path = staticmethod( IdentityAwareProxyAdminServiceClient.common_billing_account_path ) @@ -718,6 +732,527 @@ async def sample_update_iap_settings(): # Done; return the response. return response + async def list_tunnel_dest_groups( + self, + request: Union[service.ListTunnelDestGroupsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTunnelDestGroupsAsyncPager: + r"""Lists the existing TunnelDestGroups. To group across all + locations, use a ``-`` as the location ID. For example: + ``/v1/projects/123/iap_tunnel/locations/-/destGroups`` + + .. code-block:: python + + from google.cloud import iap_v1 + + async def sample_list_tunnel_dest_groups(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.ListTunnelDestGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tunnel_dest_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.ListTunnelDestGroupsRequest, dict]): + The request object. The request to ListTunnelDestGroups. + parent (:class:`str`): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + A ``-`` can be used for the location to group across all + locations. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsAsyncPager: + The response from + ListTunnelDestGroups. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = service.ListTunnelDestGroupsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_tunnel_dest_groups, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListTunnelDestGroupsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_tunnel_dest_group( + self, + request: Union[service.CreateTunnelDestGroupRequest, dict] = None, + *, + parent: str = None, + tunnel_dest_group: service.TunnelDestGroup = None, + tunnel_dest_group_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Creates a new TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + async def sample_create_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.CreateTunnelDestGroupRequest( + parent="parent_value", + tunnel_dest_group=tunnel_dest_group, + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Make the request + response = await client.create_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.CreateTunnelDestGroupRequest, dict]): + The request object. The request to + CreateTunnelDestGroup. + parent (:class:`str`): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tunnel_dest_group (:class:`google.cloud.iap_v1.types.TunnelDestGroup`): + Required. The TunnelDestGroup to + create. + + This corresponds to the ``tunnel_dest_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tunnel_dest_group_id (:class:`str`): + Required. The ID to use for the TunnelDestGroup, which + becomes the final component of the resource name. + + This value must be 4-63 characters, and valid characters + are ``[a-z][0-9]-``. + + This corresponds to the ``tunnel_dest_group_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, tunnel_dest_group, tunnel_dest_group_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = service.CreateTunnelDestGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tunnel_dest_group is not None: + request.tunnel_dest_group = tunnel_dest_group + if tunnel_dest_group_id is not None: + request.tunnel_dest_group_id = tunnel_dest_group_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_tunnel_dest_group, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_tunnel_dest_group( + self, + request: Union[service.GetTunnelDestGroupRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Retrieves an existing TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + async def sample_get_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.GetTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.GetTunnelDestGroupRequest, dict]): + The request object. The request to GetTunnelDestGroup. + name (:class:`str`): + Required. Name of the TunnelDestGroup to be fetched. In + the following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = service.GetTunnelDestGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_tunnel_dest_group, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_tunnel_dest_group( + self, + request: Union[service.DeleteTunnelDestGroupRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + async def sample_delete_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.DeleteTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + await client.delete_tunnel_dest_group(request=request) + + Args: + request (Union[google.cloud.iap_v1.types.DeleteTunnelDestGroupRequest, dict]): + The request object. The request to + DeleteTunnelDestGroup. + name (:class:`str`): + Required. Name of the TunnelDestGroup to delete. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = service.DeleteTunnelDestGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_tunnel_dest_group, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_tunnel_dest_group( + self, + request: Union[service.UpdateTunnelDestGroupRequest, dict] = None, + *, + tunnel_dest_group: service.TunnelDestGroup = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Updates a TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + async def sample_update_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.UpdateTunnelDestGroupRequest( + tunnel_dest_group=tunnel_dest_group, + ) + + # Make the request + response = await client.update_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.UpdateTunnelDestGroupRequest, dict]): + The request object. The request to + UpdateTunnelDestGroup. + tunnel_dest_group (:class:`google.cloud.iap_v1.types.TunnelDestGroup`): + Required. The new values for the + TunnelDestGroup. + + This corresponds to the ``tunnel_dest_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + A field mask that specifies which IAP + settings to update. If omitted, then all + of the settings are updated. See + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([tunnel_dest_group, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = service.UpdateTunnelDestGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tunnel_dest_group is not None: + request.tunnel_dest_group = tunnel_dest_group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_tunnel_dest_group, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("tunnel_dest_group.name", request.tunnel_dest_group.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py index 640fadc02b33..4589ab8b67c0 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py @@ -36,7 +36,9 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import pagers from google.cloud.iap_v1.types import service from .transports.base import ( @@ -172,6 +174,47 @@ def transport(self) -> IdentityAwareProxyAdminServiceTransport: """ return self._transport + @staticmethod + def tunnel_dest_group_path( + project: str, + location: str, + dest_group: str, + ) -> str: + """Returns a fully-qualified tunnel_dest_group string.""" + return "projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}".format( + project=project, + location=location, + dest_group=dest_group, + ) + + @staticmethod + def parse_tunnel_dest_group_path(path: str) -> Dict[str, str]: + """Parses a tunnel_dest_group path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/iap_tunnel/locations/(?P.+?)/destGroups/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def tunnel_location_path( + project: str, + location: str, + ) -> str: + """Returns a fully-qualified tunnel_location string.""" + return "projects/{project}/iap_tunnel/locations/{location}".format( + project=project, + location=location, + ) + + @staticmethod + def parse_tunnel_location_path(path: str) -> Dict[str, str]: + """Parses a tunnel_location path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/iap_tunnel/locations/(?P.+?)$", path + ) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path( billing_account: str, @@ -918,6 +961,527 @@ def sample_update_iap_settings(): # Done; return the response. return response + def list_tunnel_dest_groups( + self, + request: Union[service.ListTunnelDestGroupsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTunnelDestGroupsPager: + r"""Lists the existing TunnelDestGroups. To group across all + locations, use a ``-`` as the location ID. For example: + ``/v1/projects/123/iap_tunnel/locations/-/destGroups`` + + .. code-block:: python + + from google.cloud import iap_v1 + + def sample_list_tunnel_dest_groups(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.ListTunnelDestGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tunnel_dest_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.ListTunnelDestGroupsRequest, dict]): + The request object. The request to ListTunnelDestGroups. + parent (str): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + A ``-`` can be used for the location to group across all + locations. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsPager: + The response from + ListTunnelDestGroups. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListTunnelDestGroupsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListTunnelDestGroupsRequest): + request = service.ListTunnelDestGroupsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_tunnel_dest_groups] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListTunnelDestGroupsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_tunnel_dest_group( + self, + request: Union[service.CreateTunnelDestGroupRequest, dict] = None, + *, + parent: str = None, + tunnel_dest_group: service.TunnelDestGroup = None, + tunnel_dest_group_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Creates a new TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + def sample_create_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.CreateTunnelDestGroupRequest( + parent="parent_value", + tunnel_dest_group=tunnel_dest_group, + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Make the request + response = client.create_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.CreateTunnelDestGroupRequest, dict]): + The request object. The request to + CreateTunnelDestGroup. + parent (str): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tunnel_dest_group (google.cloud.iap_v1.types.TunnelDestGroup): + Required. The TunnelDestGroup to + create. + + This corresponds to the ``tunnel_dest_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tunnel_dest_group_id (str): + Required. The ID to use for the TunnelDestGroup, which + becomes the final component of the resource name. + + This value must be 4-63 characters, and valid characters + are ``[a-z][0-9]-``. + + This corresponds to the ``tunnel_dest_group_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, tunnel_dest_group, tunnel_dest_group_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateTunnelDestGroupRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateTunnelDestGroupRequest): + request = service.CreateTunnelDestGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tunnel_dest_group is not None: + request.tunnel_dest_group = tunnel_dest_group + if tunnel_dest_group_id is not None: + request.tunnel_dest_group_id = tunnel_dest_group_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_tunnel_dest_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_tunnel_dest_group( + self, + request: Union[service.GetTunnelDestGroupRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Retrieves an existing TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + def sample_get_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.GetTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.GetTunnelDestGroupRequest, dict]): + The request object. The request to GetTunnelDestGroup. + name (str): + Required. Name of the TunnelDestGroup to be fetched. In + the following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetTunnelDestGroupRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetTunnelDestGroupRequest): + request = service.GetTunnelDestGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_tunnel_dest_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_tunnel_dest_group( + self, + request: Union[service.DeleteTunnelDestGroupRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + def sample_delete_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.DeleteTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_tunnel_dest_group(request=request) + + Args: + request (Union[google.cloud.iap_v1.types.DeleteTunnelDestGroupRequest, dict]): + The request object. The request to + DeleteTunnelDestGroup. + name (str): + Required. Name of the TunnelDestGroup to delete. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteTunnelDestGroupRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteTunnelDestGroupRequest): + request = service.DeleteTunnelDestGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_tunnel_dest_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_tunnel_dest_group( + self, + request: Union[service.UpdateTunnelDestGroupRequest, dict] = None, + *, + tunnel_dest_group: service.TunnelDestGroup = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.TunnelDestGroup: + r"""Updates a TunnelDestGroup. + + .. code-block:: python + + from google.cloud import iap_v1 + + def sample_update_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.UpdateTunnelDestGroupRequest( + tunnel_dest_group=tunnel_dest_group, + ) + + # Make the request + response = client.update_tunnel_dest_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.iap_v1.types.UpdateTunnelDestGroupRequest, dict]): + The request object. The request to + UpdateTunnelDestGroup. + tunnel_dest_group (google.cloud.iap_v1.types.TunnelDestGroup): + Required. The new values for the + TunnelDestGroup. + + This corresponds to the ``tunnel_dest_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + A field mask that specifies which IAP + settings to update. If omitted, then all + of the settings are updated. See + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.iap_v1.types.TunnelDestGroup: + A TunnelDestGroup. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([tunnel_dest_group, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateTunnelDestGroupRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateTunnelDestGroupRequest): + request = service.UpdateTunnelDestGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tunnel_dest_group is not None: + request.tunnel_dest_group = tunnel_dest_group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_tunnel_dest_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("tunnel_dest_group.name", request.tunnel_dest_group.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self): return self diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py new file mode 100644 index 000000000000..55d09d6d7ce0 --- /dev/null +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import ( + Any, + AsyncIterator, + Awaitable, + Callable, + Iterator, + Optional, + Sequence, + Tuple, +) + +from google.cloud.iap_v1.types import service + + +class ListTunnelDestGroupsPager: + """A pager for iterating through ``list_tunnel_dest_groups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.iap_v1.types.ListTunnelDestGroupsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``tunnel_dest_groups`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTunnelDestGroups`` requests and continue to iterate + through the ``tunnel_dest_groups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.iap_v1.types.ListTunnelDestGroupsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., service.ListTunnelDestGroupsResponse], + request: service.ListTunnelDestGroupsRequest, + response: service.ListTunnelDestGroupsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.iap_v1.types.ListTunnelDestGroupsRequest): + The initial request object. + response (google.cloud.iap_v1.types.ListTunnelDestGroupsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListTunnelDestGroupsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListTunnelDestGroupsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[service.TunnelDestGroup]: + for page in self.pages: + yield from page.tunnel_dest_groups + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListTunnelDestGroupsAsyncPager: + """A pager for iterating through ``list_tunnel_dest_groups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.iap_v1.types.ListTunnelDestGroupsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``tunnel_dest_groups`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTunnelDestGroups`` requests and continue to iterate + through the ``tunnel_dest_groups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.iap_v1.types.ListTunnelDestGroupsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[service.ListTunnelDestGroupsResponse]], + request: service.ListTunnelDestGroupsRequest, + response: service.ListTunnelDestGroupsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.iap_v1.types.ListTunnelDestGroupsRequest): + The initial request object. + response (google.cloud.iap_v1.types.ListTunnelDestGroupsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListTunnelDestGroupsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListTunnelDestGroupsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[service.TunnelDestGroup]: + async def async_generator(): + async for page in self.pages: + for response in page.tunnel_dest_groups: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py index d299b2b4b88e..51c9d9427fd3 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py @@ -25,6 +25,7 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +from google.protobuf import empty_pb2 # type: ignore import pkg_resources from google.cloud.iap_v1.types import service @@ -148,6 +149,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.list_tunnel_dest_groups: gapic_v1.method.wrap_method( + self.list_tunnel_dest_groups, + default_timeout=None, + client_info=client_info, + ), + self.create_tunnel_dest_group: gapic_v1.method.wrap_method( + self.create_tunnel_dest_group, + default_timeout=None, + client_info=client_info, + ), + self.get_tunnel_dest_group: gapic_v1.method.wrap_method( + self.get_tunnel_dest_group, + default_timeout=None, + client_info=client_info, + ), + self.delete_tunnel_dest_group: gapic_v1.method.wrap_method( + self.delete_tunnel_dest_group, + default_timeout=None, + client_info=client_info, + ), + self.update_tunnel_dest_group: gapic_v1.method.wrap_method( + self.update_tunnel_dest_group, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -207,6 +233,54 @@ def update_iap_settings( ]: raise NotImplementedError() + @property + def list_tunnel_dest_groups( + self, + ) -> Callable[ + [service.ListTunnelDestGroupsRequest], + Union[ + service.ListTunnelDestGroupsResponse, + Awaitable[service.ListTunnelDestGroupsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_tunnel_dest_group( + self, + ) -> Callable[ + [service.CreateTunnelDestGroupRequest], + Union[service.TunnelDestGroup, Awaitable[service.TunnelDestGroup]], + ]: + raise NotImplementedError() + + @property + def get_tunnel_dest_group( + self, + ) -> Callable[ + [service.GetTunnelDestGroupRequest], + Union[service.TunnelDestGroup, Awaitable[service.TunnelDestGroup]], + ]: + raise NotImplementedError() + + @property + def delete_tunnel_dest_group( + self, + ) -> Callable[ + [service.DeleteTunnelDestGroupRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def update_tunnel_dest_group( + self, + ) -> Callable[ + [service.UpdateTunnelDestGroupRequest], + Union[service.TunnelDestGroup, Awaitable[service.TunnelDestGroup]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py index 351c7a77811d..16510031fa89 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py @@ -22,6 +22,7 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from google.cloud.iap_v1.types import service @@ -374,6 +375,140 @@ def update_iap_settings( ) return self._stubs["update_iap_settings"] + @property + def list_tunnel_dest_groups( + self, + ) -> Callable[ + [service.ListTunnelDestGroupsRequest], service.ListTunnelDestGroupsResponse + ]: + r"""Return a callable for the list tunnel dest groups method over gRPC. + + Lists the existing TunnelDestGroups. To group across all + locations, use a ``-`` as the location ID. For example: + ``/v1/projects/123/iap_tunnel/locations/-/destGroups`` + + Returns: + Callable[[~.ListTunnelDestGroupsRequest], + ~.ListTunnelDestGroupsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_tunnel_dest_groups" not in self._stubs: + self._stubs["list_tunnel_dest_groups"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/ListTunnelDestGroups", + request_serializer=service.ListTunnelDestGroupsRequest.serialize, + response_deserializer=service.ListTunnelDestGroupsResponse.deserialize, + ) + return self._stubs["list_tunnel_dest_groups"] + + @property + def create_tunnel_dest_group( + self, + ) -> Callable[[service.CreateTunnelDestGroupRequest], service.TunnelDestGroup]: + r"""Return a callable for the create tunnel dest group method over gRPC. + + Creates a new TunnelDestGroup. + + Returns: + Callable[[~.CreateTunnelDestGroupRequest], + ~.TunnelDestGroup]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_tunnel_dest_group" not in self._stubs: + self._stubs["create_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/CreateTunnelDestGroup", + request_serializer=service.CreateTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["create_tunnel_dest_group"] + + @property + def get_tunnel_dest_group( + self, + ) -> Callable[[service.GetTunnelDestGroupRequest], service.TunnelDestGroup]: + r"""Return a callable for the get tunnel dest group method over gRPC. + + Retrieves an existing TunnelDestGroup. + + Returns: + Callable[[~.GetTunnelDestGroupRequest], + ~.TunnelDestGroup]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_tunnel_dest_group" not in self._stubs: + self._stubs["get_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/GetTunnelDestGroup", + request_serializer=service.GetTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["get_tunnel_dest_group"] + + @property + def delete_tunnel_dest_group( + self, + ) -> Callable[[service.DeleteTunnelDestGroupRequest], empty_pb2.Empty]: + r"""Return a callable for the delete tunnel dest group method over gRPC. + + Deletes a TunnelDestGroup. + + Returns: + Callable[[~.DeleteTunnelDestGroupRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_tunnel_dest_group" not in self._stubs: + self._stubs["delete_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/DeleteTunnelDestGroup", + request_serializer=service.DeleteTunnelDestGroupRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_tunnel_dest_group"] + + @property + def update_tunnel_dest_group( + self, + ) -> Callable[[service.UpdateTunnelDestGroupRequest], service.TunnelDestGroup]: + r"""Return a callable for the update tunnel dest group method over gRPC. + + Updates a TunnelDestGroup. + + Returns: + Callable[[~.UpdateTunnelDestGroupRequest], + ~.TunnelDestGroup]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_tunnel_dest_group" not in self._stubs: + self._stubs["update_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/UpdateTunnelDestGroup", + request_serializer=service.UpdateTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["update_tunnel_dest_group"] + def close(self): self.grpc_channel.close() diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py index 40143205d8b5..2d4cf53c7d85 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py @@ -21,6 +21,7 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -377,6 +378,147 @@ def update_iap_settings( ) return self._stubs["update_iap_settings"] + @property + def list_tunnel_dest_groups( + self, + ) -> Callable[ + [service.ListTunnelDestGroupsRequest], + Awaitable[service.ListTunnelDestGroupsResponse], + ]: + r"""Return a callable for the list tunnel dest groups method over gRPC. + + Lists the existing TunnelDestGroups. To group across all + locations, use a ``-`` as the location ID. For example: + ``/v1/projects/123/iap_tunnel/locations/-/destGroups`` + + Returns: + Callable[[~.ListTunnelDestGroupsRequest], + Awaitable[~.ListTunnelDestGroupsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_tunnel_dest_groups" not in self._stubs: + self._stubs["list_tunnel_dest_groups"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/ListTunnelDestGroups", + request_serializer=service.ListTunnelDestGroupsRequest.serialize, + response_deserializer=service.ListTunnelDestGroupsResponse.deserialize, + ) + return self._stubs["list_tunnel_dest_groups"] + + @property + def create_tunnel_dest_group( + self, + ) -> Callable[ + [service.CreateTunnelDestGroupRequest], Awaitable[service.TunnelDestGroup] + ]: + r"""Return a callable for the create tunnel dest group method over gRPC. + + Creates a new TunnelDestGroup. + + Returns: + Callable[[~.CreateTunnelDestGroupRequest], + Awaitable[~.TunnelDestGroup]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_tunnel_dest_group" not in self._stubs: + self._stubs["create_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/CreateTunnelDestGroup", + request_serializer=service.CreateTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["create_tunnel_dest_group"] + + @property + def get_tunnel_dest_group( + self, + ) -> Callable[ + [service.GetTunnelDestGroupRequest], Awaitable[service.TunnelDestGroup] + ]: + r"""Return a callable for the get tunnel dest group method over gRPC. + + Retrieves an existing TunnelDestGroup. + + Returns: + Callable[[~.GetTunnelDestGroupRequest], + Awaitable[~.TunnelDestGroup]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_tunnel_dest_group" not in self._stubs: + self._stubs["get_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/GetTunnelDestGroup", + request_serializer=service.GetTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["get_tunnel_dest_group"] + + @property + def delete_tunnel_dest_group( + self, + ) -> Callable[[service.DeleteTunnelDestGroupRequest], Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete tunnel dest group method over gRPC. + + Deletes a TunnelDestGroup. + + Returns: + Callable[[~.DeleteTunnelDestGroupRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_tunnel_dest_group" not in self._stubs: + self._stubs["delete_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/DeleteTunnelDestGroup", + request_serializer=service.DeleteTunnelDestGroupRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_tunnel_dest_group"] + + @property + def update_tunnel_dest_group( + self, + ) -> Callable[ + [service.UpdateTunnelDestGroupRequest], Awaitable[service.TunnelDestGroup] + ]: + r"""Return a callable for the update tunnel dest group method over gRPC. + + Updates a TunnelDestGroup. + + Returns: + Callable[[~.UpdateTunnelDestGroupRequest], + Awaitable[~.TunnelDestGroup]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_tunnel_dest_group" not in self._stubs: + self._stubs["update_tunnel_dest_group"] = self.grpc_channel.unary_unary( + "/google.cloud.iap.v1.IdentityAwareProxyAdminService/UpdateTunnelDestGroup", + request_serializer=service.UpdateTunnelDestGroupRequest.serialize, + response_deserializer=service.TunnelDestGroup.deserialize, + ) + return self._stubs["update_tunnel_dest_group"] + def close(self): return self.grpc_channel.close() diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py index 7eafb1b1a3fe..4b4b7d1cc527 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py @@ -295,13 +295,13 @@ async def create_brand( r"""Constructs a new OAuth brand for the project if one does not exist. The created brand is "internal only", meaning that OAuth clients created under it only accept - requests from users who belong to the same G Suite - organization as the project. The brand is created in an - un-reviewed status. NOTE: The "internal only" status can - be manually changed in the Google Cloud console. - Requires that a brand does not already exist for the - project, and that the specified support email is owned - by the caller. + requests from users who belong to the same Google + Workspace organization as the project. The brand is + created in an un-reviewed status. NOTE: The "internal + only" status can be manually changed in the Google Cloud + Console. Requires that a brand does not already exist + for the project, and that the specified support email is + owned by the caller. .. code-block:: python diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py index b45cf5b588c1..af44957c5404 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py @@ -497,13 +497,13 @@ def create_brand( r"""Constructs a new OAuth brand for the project if one does not exist. The created brand is "internal only", meaning that OAuth clients created under it only accept - requests from users who belong to the same G Suite - organization as the project. The brand is created in an - un-reviewed status. NOTE: The "internal only" status can - be manually changed in the Google Cloud console. - Requires that a brand does not already exist for the - project, and that the specified support email is owned - by the caller. + requests from users who belong to the same Google + Workspace organization as the project. The brand is + created in an un-reviewed status. NOTE: The "internal + only" status can be manually changed in the Google Cloud + Console. Requires that a brand does not already exist + for the project, and that the specified support email is + owned by the caller. .. code-block:: python diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py index b1c5867062b2..1fe3510f27f0 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py @@ -264,13 +264,13 @@ def create_brand(self) -> Callable[[service.CreateBrandRequest], service.Brand]: Constructs a new OAuth brand for the project if one does not exist. The created brand is "internal only", meaning that OAuth clients created under it only accept - requests from users who belong to the same G Suite - organization as the project. The brand is created in an - un-reviewed status. NOTE: The "internal only" status can - be manually changed in the Google Cloud console. - Requires that a brand does not already exist for the - project, and that the specified support email is owned - by the caller. + requests from users who belong to the same Google + Workspace organization as the project. The brand is + created in an un-reviewed status. NOTE: The "internal + only" status can be manually changed in the Google Cloud + Console. Requires that a brand does not already exist + for the project, and that the specified support email is + owned by the caller. Returns: Callable[[~.CreateBrandRequest], diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py index 4fbc5a2d015f..491dcc8cebf8 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py @@ -269,13 +269,13 @@ def create_brand( Constructs a new OAuth brand for the project if one does not exist. The created brand is "internal only", meaning that OAuth clients created under it only accept - requests from users who belong to the same G Suite - organization as the project. The brand is created in an - un-reviewed status. NOTE: The "internal only" status can - be manually changed in the Google Cloud console. - Requires that a brand does not already exist for the - project, and that the specified support email is owned - by the caller. + requests from users who belong to the same Google + Workspace organization as the project. The brand is + created in an un-reviewed status. NOTE: The "internal + only" status can be manually changed in the Google Cloud + Console. Requires that a brand does not already exist + for the project, and that the specified support email is + owned by the caller. Returns: Callable[[~.CreateBrandRequest], diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/types/__init__.py b/packages/google-cloud-iap/google/cloud/iap_v1/types/__init__.py index 09bcd32c624f..1a7a56e7e83e 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/types/__init__.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/types/__init__.py @@ -21,21 +21,29 @@ CorsSettings, CreateBrandRequest, CreateIdentityAwareProxyClientRequest, + CreateTunnelDestGroupRequest, CsmSettings, DeleteIdentityAwareProxyClientRequest, + DeleteTunnelDestGroupRequest, GcipSettings, GetBrandRequest, GetIapSettingsRequest, GetIdentityAwareProxyClientRequest, + GetTunnelDestGroupRequest, IapSettings, IdentityAwareProxyClient, ListBrandsRequest, ListBrandsResponse, ListIdentityAwareProxyClientsRequest, ListIdentityAwareProxyClientsResponse, + ListTunnelDestGroupsRequest, + ListTunnelDestGroupsResponse, OAuthSettings, + ReauthSettings, ResetIdentityAwareProxyClientSecretRequest, + TunnelDestGroup, UpdateIapSettingsRequest, + UpdateTunnelDestGroupRequest, ) __all__ = ( @@ -46,19 +54,27 @@ "CorsSettings", "CreateBrandRequest", "CreateIdentityAwareProxyClientRequest", + "CreateTunnelDestGroupRequest", "CsmSettings", "DeleteIdentityAwareProxyClientRequest", + "DeleteTunnelDestGroupRequest", "GcipSettings", "GetBrandRequest", "GetIapSettingsRequest", "GetIdentityAwareProxyClientRequest", + "GetTunnelDestGroupRequest", "IapSettings", "IdentityAwareProxyClient", "ListBrandsRequest", "ListBrandsResponse", "ListIdentityAwareProxyClientsRequest", "ListIdentityAwareProxyClientsResponse", + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", "OAuthSettings", + "ReauthSettings", "ResetIdentityAwareProxyClientSecretRequest", + "TunnelDestGroup", "UpdateIapSettingsRequest", + "UpdateTunnelDestGroupRequest", ) diff --git a/packages/google-cloud-iap/google/cloud/iap_v1/types/service.py b/packages/google-cloud-iap/google/cloud/iap_v1/types/service.py index dddeac75dc7f..c9d9e318d173 100644 --- a/packages/google-cloud-iap/google/cloud/iap_v1/types/service.py +++ b/packages/google-cloud-iap/google/cloud/iap_v1/types/service.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore import proto # type: ignore @@ -20,6 +21,13 @@ __protobuf__ = proto.module( package="google.cloud.iap.v1", manifest={ + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", + "CreateTunnelDestGroupRequest", + "GetTunnelDestGroupRequest", + "DeleteTunnelDestGroupRequest", + "UpdateTunnelDestGroupRequest", + "TunnelDestGroup", "GetIapSettingsRequest", "UpdateIapSettingsRequest", "IapSettings", @@ -27,6 +35,7 @@ "GcipSettings", "CorsSettings", "OAuthSettings", + "ReauthSettings", "ApplicationSettings", "CsmSettings", "AccessDeniedPageSettings", @@ -46,6 +55,194 @@ ) +class ListTunnelDestGroupsRequest(proto.Message): + r"""The request to ListTunnelDestGroups. + + Attributes: + parent (str): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + A ``-`` can be used for the location to group across all + locations. + page_size (int): + The maximum number of groups to return. The + service might return fewer than this value. + If unspecified, at most 100 groups are returned. + The maximum value is 1000; values above 1000 are + coerced to 1000. + page_token (str): + A page token, received from a previous + ``ListTunnelDestGroups`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListTunnelDestGroups`` must match the call that provided + the page token. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListTunnelDestGroupsResponse(proto.Message): + r"""The response from ListTunnelDestGroups. + + Attributes: + tunnel_dest_groups (Sequence[google.cloud.iap_v1.types.TunnelDestGroup]): + TunnelDestGroup existing in the project. + next_page_token (str): + A token that you can send as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + tunnel_dest_groups = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="TunnelDestGroup", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class CreateTunnelDestGroupRequest(proto.Message): + r"""The request to CreateTunnelDestGroup. + + Attributes: + parent (str): + Required. Google Cloud Project ID and location. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}``. + tunnel_dest_group (google.cloud.iap_v1.types.TunnelDestGroup): + Required. The TunnelDestGroup to create. + tunnel_dest_group_id (str): + Required. The ID to use for the TunnelDestGroup, which + becomes the final component of the resource name. + + This value must be 4-63 characters, and valid characters are + ``[a-z][0-9]-``. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + tunnel_dest_group = proto.Field( + proto.MESSAGE, + number=2, + message="TunnelDestGroup", + ) + tunnel_dest_group_id = proto.Field( + proto.STRING, + number=3, + ) + + +class GetTunnelDestGroupRequest(proto.Message): + r"""The request to GetTunnelDestGroup. + + Attributes: + name (str): + Required. Name of the TunnelDestGroup to be fetched. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteTunnelDestGroupRequest(proto.Message): + r"""The request to DeleteTunnelDestGroup. + + Attributes: + name (str): + Required. Name of the TunnelDestGroup to delete. In the + following format: + ``projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateTunnelDestGroupRequest(proto.Message): + r"""The request to UpdateTunnelDestGroup. + + Attributes: + tunnel_dest_group (google.cloud.iap_v1.types.TunnelDestGroup): + Required. The new values for the + TunnelDestGroup. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + A field mask that specifies which IAP + settings to update. If omitted, then all of the + settings are updated. See + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + tunnel_dest_group = proto.Field( + proto.MESSAGE, + number=1, + message="TunnelDestGroup", + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class TunnelDestGroup(proto.Message): + r"""A TunnelDestGroup. + + Attributes: + name (str): + Required. Immutable. Identifier for the + TunnelDestGroup. Must be unique within the + project. + cidrs (Sequence[str]): + null List of CIDRs that this group applies + to. + fqdns (Sequence[str]): + null List of FQDNs that this group applies + to. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + cidrs = proto.RepeatedField( + proto.STRING, + number=2, + ) + fqdns = proto.RepeatedField( + proto.STRING, + number=3, + ) + + class GetIapSettingsRequest(proto.Message): r"""The request sent to GetIapSettings. @@ -132,6 +329,9 @@ class AccessSettings(proto.Message): via IAP. oauth_settings (google.cloud.iap_v1.types.OAuthSettings): Settings to configure IAP's OAuth behavior. + reauth_settings (google.cloud.iap_v1.types.ReauthSettings): + Settings to configure reauthentication + policies in IAP. """ gcip_settings = proto.Field( @@ -149,6 +349,11 @@ class AccessSettings(proto.Message): number=3, message="OAuthSettings", ) + reauth_settings = proto.Field( + proto.MESSAGE, + number=6, + message="ReauthSettings", + ) class GcipSettings(proto.Message): @@ -223,6 +428,52 @@ class OAuthSettings(proto.Message): ) +class ReauthSettings(proto.Message): + r"""Configuration for IAP reauthentication policies. + + Attributes: + method (google.cloud.iap_v1.types.ReauthSettings.Method): + Reauth method required by the policy. + max_age (google.protobuf.duration_pb2.Duration): + Reauth session lifetime, how long before a + user has to reauthenticate again. + policy_type (google.cloud.iap_v1.types.ReauthSettings.PolicyType): + How IAP determines the effective policy in + cases of hierarchial policies. Policies are + merged from higher in the hierarchy to lower in + the hierarchy. + """ + + class Method(proto.Enum): + r"""Types of reauthentication methods supported by IAP.""" + METHOD_UNSPECIFIED = 0 + LOGIN = 1 + PASSWORD = 2 + SECURE_KEY = 3 + + class PolicyType(proto.Enum): + r"""Type of policy in the case of hierarchial policies.""" + POLICY_TYPE_UNSPECIFIED = 0 + MINIMUM = 1 + DEFAULT = 2 + + method = proto.Field( + proto.ENUM, + number=1, + enum=Method, + ) + max_age = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + policy_type = proto.Field( + proto.ENUM, + number=3, + enum=PolicyType, + ) + + class ApplicationSettings(proto.Message): r"""Wrapper over application specific settings for IAP. diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py new file mode 100644 index 000000000000..bb1cf0723ded --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_async] +from google.cloud import iap_v1 + + +async def sample_create_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.CreateTunnelDestGroupRequest( + parent="parent_value", + tunnel_dest_group=tunnel_dest_group, + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Make the request + response = await client.create_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_async] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py new file mode 100644 index 000000000000..e48765cdf268 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_sync] +from google.cloud import iap_v1 + + +def sample_create_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.CreateTunnelDestGroupRequest( + parent="parent_value", + tunnel_dest_group=tunnel_dest_group, + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Make the request + response = client.create_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_sync] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py new file mode 100644 index 000000000000..cdd5ca71eeae --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_async] +from google.cloud import iap_v1 + + +async def sample_delete_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.DeleteTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + await client.delete_tunnel_dest_group(request=request) + + +# [END iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_async] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py new file mode 100644 index 000000000000..3122a18e6853 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_sync] +from google.cloud import iap_v1 + + +def sample_delete_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.DeleteTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_tunnel_dest_group(request=request) + + +# [END iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_sync] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py new file mode 100644 index 000000000000..4ecfe6d75807 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_async] +from google.cloud import iap_v1 + + +async def sample_get_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.GetTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_async] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py new file mode 100644 index 000000000000..a08b2e79e07c --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_sync] +from google.cloud import iap_v1 + + +def sample_get_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.GetTunnelDestGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_sync] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py new file mode 100644 index 000000000000..a40f93ffcb76 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTunnelDestGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_async] +from google.cloud import iap_v1 + + +async def sample_list_tunnel_dest_groups(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + request = iap_v1.ListTunnelDestGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tunnel_dest_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_async] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py new file mode 100644 index 000000000000..2805b3e42ab4 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTunnelDestGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_sync] +from google.cloud import iap_v1 + + +def sample_list_tunnel_dest_groups(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + request = iap_v1.ListTunnelDestGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tunnel_dest_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_sync] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py new file mode 100644 index 000000000000..89e71d25922d --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_async] +from google.cloud import iap_v1 + + +async def sample_update_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.UpdateTunnelDestGroupRequest( + tunnel_dest_group=tunnel_dest_group, + ) + + # Make the request + response = await client.update_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_async] diff --git a/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py new file mode 100644 index 000000000000..fd209e87bf83 --- /dev/null +++ b/packages/google-cloud-iap/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTunnelDestGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iap + + +# [START iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_sync] +from google.cloud import iap_v1 + + +def sample_update_tunnel_dest_group(): + # Create a client + client = iap_v1.IdentityAwareProxyAdminServiceClient() + + # Initialize request argument(s) + tunnel_dest_group = iap_v1.TunnelDestGroup() + tunnel_dest_group.name = "name_value" + + request = iap_v1.UpdateTunnelDestGroupRequest( + tunnel_dest_group=tunnel_dest_group, + ) + + # Make the request + response = client.update_tunnel_dest_group(request=request) + + # Handle the response + print(response) + +# [END iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_sync] diff --git a/packages/google-cloud-iap/samples/generated_samples/snippet_metadata_iap_v1.json b/packages/google-cloud-iap/samples/generated_samples/snippet_metadata_iap_v1.json index 757a41ae0bfa..d439c4340e67 100644 --- a/packages/google-cloud-iap/samples/generated_samples/snippet_metadata_iap_v1.json +++ b/packages/google-cloud-iap/samples/generated_samples/snippet_metadata_iap_v1.json @@ -10,6 +10,338 @@ "name": "google-cloud-iap" }, "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.create_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.CreateTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "CreateTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateTunnelDestGroupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tunnel_dest_group", + "type": "google.cloud.iap_v1.types.TunnelDestGroup" + }, + { + "name": "tunnel_dest_group_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "create_tunnel_dest_group" + }, + "description": "Sample for CreateTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.create_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.CreateTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "CreateTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateTunnelDestGroupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tunnel_dest_group", + "type": "google.cloud.iap_v1.types.TunnelDestGroup" + }, + { + "name": "tunnel_dest_group_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "create_tunnel_dest_group" + }, + "description": "Sample for CreateTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.delete_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.DeleteTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "DeleteTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.DeleteTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_tunnel_dest_group" + }, + "description": "Sample for DeleteTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.delete_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.DeleteTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "DeleteTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.DeleteTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_tunnel_dest_group" + }, + "description": "Sample for DeleteTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py" + }, { "canonical": true, "clientMethod": { @@ -20,17 +352,327 @@ }, "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.get_iam_policy", "method": { - "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIamPolicy", + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIamPolicy", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 34, + "start": 32, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 35, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_iam_policy", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIamPolicy", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 34, + "start": 32, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 35, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.get_iap_settings", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIapSettings", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "GetIapSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetIapSettingsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.IapSettings", + "shortName": "get_iap_settings" + }, + "description": "Sample for GetIapSettings", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_iap_settings", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIapSettings", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "GetIapSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetIapSettingsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.IapSettings", + "shortName": "get_iap_settings" + }, + "description": "Sample for GetIapSettings", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.get_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetTunnelDestGroup", "service": { "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "GetIamPolicy" + "shortName": "GetTunnelDestGroup" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.iap_v1.types.GetTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -45,47 +687,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "get_tunnel_dest_group" }, - "description": "Sample for GetIamPolicy", - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py", + "description": "Sample for GetTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_async", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_async", "segments": [ { - "end": 45, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 44, "start": 27, "type": "SHORT" }, { - "end": 34, - "start": 32, + "end": 33, + "start": 31, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 35, + "end": 38, + "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py" + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py" }, { "canonical": true, @@ -94,19 +736,23 @@ "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", "shortName": "IdentityAwareProxyAdminServiceClient" }, - "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_iam_policy", + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_tunnel_dest_group", "method": { - "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIamPolicy", + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetTunnelDestGroup", "service": { "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "GetIamPolicy" + "shortName": "GetTunnelDestGroup" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.iap_v1.types.GetTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -121,47 +767,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "get_tunnel_dest_group" }, - "description": "Sample for GetIamPolicy", - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py", + "description": "Sample for GetTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_sync", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_sync", "segments": [ { - "end": 45, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 44, "start": 27, "type": "SHORT" }, { - "end": 34, - "start": 32, + "end": 33, + "start": 31, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 35, + "end": 38, + "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py" + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py" }, { "canonical": true, @@ -171,19 +817,23 @@ "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", "shortName": "IdentityAwareProxyAdminServiceAsyncClient" }, - "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.get_iap_settings", + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.list_tunnel_dest_groups", "method": { - "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIapSettings", + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.ListTunnelDestGroups", "service": { "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "GetIapSettings" + "shortName": "ListTunnelDestGroups" }, "parameters": [ { "name": "request", - "type": "google.cloud.iap_v1.types.GetIapSettingsRequest" + "type": "google.cloud.iap_v1.types.ListTunnelDestGroupsRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -198,22 +848,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.iap_v1.types.IapSettings", - "shortName": "get_iap_settings" + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsAsyncPager", + "shortName": "list_tunnel_dest_groups" }, - "description": "Sample for GetIapSettings", - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_async.py", + "description": "Sample for ListTunnelDestGroups", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_async", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -233,12 +883,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_async.py" + "title": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py" }, { "canonical": true, @@ -247,19 +897,23 @@ "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", "shortName": "IdentityAwareProxyAdminServiceClient" }, - "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_iap_settings", + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.list_tunnel_dest_groups", "method": { - "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetIapSettings", + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.ListTunnelDestGroups", "service": { "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "GetIapSettings" + "shortName": "ListTunnelDestGroups" }, "parameters": [ { "name": "request", - "type": "google.cloud.iap_v1.types.GetIapSettingsRequest" + "type": "google.cloud.iap_v1.types.ListTunnelDestGroupsRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -274,22 +928,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.iap_v1.types.IapSettings", - "shortName": "get_iap_settings" + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsPager", + "shortName": "list_tunnel_dest_groups" }, - "description": "Sample for GetIapSettings", - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_sync.py", + "description": "Sample for ListTunnelDestGroups", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_sync", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, @@ -309,12 +963,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, + "end": 46, "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_sync.py" + "title": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py" }, { "canonical": true, @@ -775,6 +1429,175 @@ ], "title": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.update_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.UpdateTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "UpdateTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.UpdateTunnelDestGroupRequest" + }, + { + "name": "tunnel_dest_group", + "type": "google.cloud.iap_v1.types.TunnelDestGroup" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "update_tunnel_dest_group" + }, + "description": "Sample for UpdateTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.update_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.UpdateTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "UpdateTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.UpdateTunnelDestGroupRequest" + }, + { + "name": "tunnel_dest_group", + "type": "google.cloud.iap_v1.types.TunnelDestGroup" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "update_tunnel_dest_group" + }, + "description": "Sample for UpdateTunnelDestGroup", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-iap/scripts/fixup_iap_v1_keywords.py b/packages/google-cloud-iap/scripts/fixup_iap_v1_keywords.py index 4eb97e426034..7359ed1b64c0 100644 --- a/packages/google-cloud-iap/scripts/fixup_iap_v1_keywords.py +++ b/packages/google-cloud-iap/scripts/fixup_iap_v1_keywords.py @@ -41,17 +41,22 @@ class iapCallTransformer(cst.CSTTransformer): METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'create_brand': ('parent', 'brand', ), 'create_identity_aware_proxy_client': ('parent', 'identity_aware_proxy_client', ), + 'create_tunnel_dest_group': ('parent', 'tunnel_dest_group', 'tunnel_dest_group_id', ), 'delete_identity_aware_proxy_client': ('name', ), + 'delete_tunnel_dest_group': ('name', ), 'get_brand': ('name', ), 'get_iam_policy': ('resource', 'options', ), 'get_iap_settings': ('name', ), 'get_identity_aware_proxy_client': ('name', ), + 'get_tunnel_dest_group': ('name', ), 'list_brands': ('parent', ), 'list_identity_aware_proxy_clients': ('parent', 'page_size', 'page_token', ), + 'list_tunnel_dest_groups': ('parent', 'page_size', 'page_token', ), 'reset_identity_aware_proxy_client_secret': ('name', ), 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_iap_settings': ('iap_settings', 'update_mask', ), + 'update_tunnel_dest_group': ('tunnel_dest_group', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/packages/google-cloud-iap/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py b/packages/google-cloud-iap/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py index fe71c9086c14..b97c34ab8783 100644 --- a/packages/google-cloud-iap/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py +++ b/packages/google-cloud-iap/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py @@ -26,6 +26,7 @@ from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore from google.type import expr_pb2 # type: ignore @@ -38,6 +39,7 @@ from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import ( IdentityAwareProxyAdminServiceAsyncClient, IdentityAwareProxyAdminServiceClient, + pagers, transports, ) from google.cloud.iap_v1.types import service @@ -1509,6 +1511,1474 @@ async def test_update_iap_settings_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + service.ListTunnelDestGroupsRequest, + dict, + ], +) +def test_list_tunnel_dest_groups(request_type, transport: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListTunnelDestGroupsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_tunnel_dest_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTunnelDestGroupsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTunnelDestGroupsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_tunnel_dest_groups_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 = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + client.list_tunnel_dest_groups() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTunnelDestGroupsRequest() + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_async( + transport: str = "grpc_asyncio", request_type=service.ListTunnelDestGroupsRequest +): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListTunnelDestGroupsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_tunnel_dest_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTunnelDestGroupsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTunnelDestGroupsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_async_from_dict(): + await test_list_tunnel_dest_groups_async(request_type=dict) + + +def test_list_tunnel_dest_groups_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTunnelDestGroupsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + call.return_value = service.ListTunnelDestGroupsResponse() + client.list_tunnel_dest_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_field_headers_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTunnelDestGroupsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListTunnelDestGroupsResponse() + ) + await client.list_tunnel_dest_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_tunnel_dest_groups_flattened(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListTunnelDestGroupsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_tunnel_dest_groups( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_tunnel_dest_groups_flattened_error(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_tunnel_dest_groups( + service.ListTunnelDestGroupsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_flattened_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListTunnelDestGroupsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListTunnelDestGroupsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_tunnel_dest_groups( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_flattened_error_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_tunnel_dest_groups( + service.ListTunnelDestGroupsRequest(), + parent="parent_value", + ) + + +def test_list_tunnel_dest_groups_pager(transport_name: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + next_page_token="abc", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[], + next_page_token="def", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + ], + next_page_token="ghi", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_tunnel_dest_groups(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, service.TunnelDestGroup) for i in results) + + +def test_list_tunnel_dest_groups_pages(transport_name: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + next_page_token="abc", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[], + next_page_token="def", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + ], + next_page_token="ghi", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + ), + RuntimeError, + ) + pages = list(client.list_tunnel_dest_groups(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_async_pager(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + next_page_token="abc", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[], + next_page_token="def", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + ], + next_page_token="ghi", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_tunnel_dest_groups( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, service.TunnelDestGroup) for i in responses) + + +@pytest.mark.asyncio +async def test_list_tunnel_dest_groups_async_pages(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tunnel_dest_groups), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + next_page_token="abc", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[], + next_page_token="def", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + ], + next_page_token="ghi", + ), + service.ListTunnelDestGroupsResponse( + tunnel_dest_groups=[ + service.TunnelDestGroup(), + service.TunnelDestGroup(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_tunnel_dest_groups(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + service.CreateTunnelDestGroupRequest, + dict, + ], +) +def test_create_tunnel_dest_group(request_type, transport: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + response = client.create_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +def test_create_tunnel_dest_group_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 = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + client.create_tunnel_dest_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateTunnelDestGroupRequest() + + +@pytest.mark.asyncio +async def test_create_tunnel_dest_group_async( + transport: str = "grpc_asyncio", request_type=service.CreateTunnelDestGroupRequest +): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + ) + response = await client.create_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +@pytest.mark.asyncio +async def test_create_tunnel_dest_group_async_from_dict(): + await test_create_tunnel_dest_group_async(request_type=dict) + + +def test_create_tunnel_dest_group_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateTunnelDestGroupRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + call.return_value = service.TunnelDestGroup() + client.create_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_tunnel_dest_group_field_headers_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateTunnelDestGroupRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + await client.create_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_tunnel_dest_group_flattened(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_tunnel_dest_group( + parent="parent_value", + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].tunnel_dest_group + mock_val = service.TunnelDestGroup(name="name_value") + assert arg == mock_val + arg = args[0].tunnel_dest_group_id + mock_val = "tunnel_dest_group_id_value" + assert arg == mock_val + + +def test_create_tunnel_dest_group_flattened_error(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_tunnel_dest_group( + service.CreateTunnelDestGroupRequest(), + parent="parent_value", + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_tunnel_dest_group_flattened_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_tunnel_dest_group( + parent="parent_value", + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].tunnel_dest_group + mock_val = service.TunnelDestGroup(name="name_value") + assert arg == mock_val + arg = args[0].tunnel_dest_group_id + mock_val = "tunnel_dest_group_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_tunnel_dest_group_flattened_error_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_tunnel_dest_group( + service.CreateTunnelDestGroupRequest(), + parent="parent_value", + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + tunnel_dest_group_id="tunnel_dest_group_id_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + service.GetTunnelDestGroupRequest, + dict, + ], +) +def test_get_tunnel_dest_group(request_type, transport: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + response = client.get_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +def test_get_tunnel_dest_group_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 = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + client.get_tunnel_dest_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetTunnelDestGroupRequest() + + +@pytest.mark.asyncio +async def test_get_tunnel_dest_group_async( + transport: str = "grpc_asyncio", request_type=service.GetTunnelDestGroupRequest +): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + ) + response = await client.get_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +@pytest.mark.asyncio +async def test_get_tunnel_dest_group_async_from_dict(): + await test_get_tunnel_dest_group_async(request_type=dict) + + +def test_get_tunnel_dest_group_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetTunnelDestGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + call.return_value = service.TunnelDestGroup() + client.get_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_tunnel_dest_group_field_headers_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetTunnelDestGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + await client.get_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_tunnel_dest_group_flattened(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_tunnel_dest_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_tunnel_dest_group_flattened_error(): + client = IdentityAwareProxyAdminServiceClient( + 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_tunnel_dest_group( + service.GetTunnelDestGroupRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_tunnel_dest_group_flattened_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_tunnel_dest_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_tunnel_dest_group_flattened_error_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_tunnel_dest_group( + service.GetTunnelDestGroupRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteTunnelDestGroupRequest, + dict, + ], +) +def test_delete_tunnel_dest_group(request_type, transport: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_tunnel_dest_group_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 = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + client.delete_tunnel_dest_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteTunnelDestGroupRequest() + + +@pytest.mark.asyncio +async def test_delete_tunnel_dest_group_async( + transport: str = "grpc_asyncio", request_type=service.DeleteTunnelDestGroupRequest +): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_tunnel_dest_group_async_from_dict(): + await test_delete_tunnel_dest_group_async(request_type=dict) + + +def test_delete_tunnel_dest_group_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteTunnelDestGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + call.return_value = None + client.delete_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_tunnel_dest_group_field_headers_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteTunnelDestGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_tunnel_dest_group_flattened(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_tunnel_dest_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_tunnel_dest_group_flattened_error(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_tunnel_dest_group( + service.DeleteTunnelDestGroupRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_tunnel_dest_group_flattened_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_tunnel_dest_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_tunnel_dest_group_flattened_error_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_tunnel_dest_group( + service.DeleteTunnelDestGroupRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateTunnelDestGroupRequest, + dict, + ], +) +def test_update_tunnel_dest_group(request_type, transport: str = "grpc"): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + response = client.update_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +def test_update_tunnel_dest_group_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 = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + client.update_tunnel_dest_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateTunnelDestGroupRequest() + + +@pytest.mark.asyncio +async def test_update_tunnel_dest_group_async( + transport: str = "grpc_asyncio", request_type=service.UpdateTunnelDestGroupRequest +): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup( + name="name_value", + cidrs=["cidrs_value"], + fqdns=["fqdns_value"], + ) + ) + response = await client.update_tunnel_dest_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateTunnelDestGroupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.TunnelDestGroup) + assert response.name == "name_value" + assert response.cidrs == ["cidrs_value"] + assert response.fqdns == ["fqdns_value"] + + +@pytest.mark.asyncio +async def test_update_tunnel_dest_group_async_from_dict(): + await test_update_tunnel_dest_group_async(request_type=dict) + + +def test_update_tunnel_dest_group_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateTunnelDestGroupRequest() + + request.tunnel_dest_group.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + call.return_value = service.TunnelDestGroup() + client.update_tunnel_dest_group(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", + "tunnel_dest_group.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_tunnel_dest_group_field_headers_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateTunnelDestGroupRequest() + + request.tunnel_dest_group.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + await client.update_tunnel_dest_group(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", + "tunnel_dest_group.name=name_value", + ) in kw["metadata"] + + +def test_update_tunnel_dest_group_flattened(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_tunnel_dest_group( + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].tunnel_dest_group + mock_val = service.TunnelDestGroup(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_tunnel_dest_group_flattened_error(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_tunnel_dest_group( + service.UpdateTunnelDestGroupRequest(), + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_tunnel_dest_group_flattened_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tunnel_dest_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.TunnelDestGroup() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.TunnelDestGroup() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_tunnel_dest_group( + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].tunnel_dest_group + mock_val = service.TunnelDestGroup(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_tunnel_dest_group_flattened_error_async(): + client = IdentityAwareProxyAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_tunnel_dest_group( + service.UpdateTunnelDestGroupRequest(), + tunnel_dest_group=service.TunnelDestGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( @@ -1653,6 +3123,11 @@ def test_identity_aware_proxy_admin_service_base_transport(): "test_iam_permissions", "get_iap_settings", "update_iap_settings", + "list_tunnel_dest_groups", + "create_tunnel_dest_group", + "get_tunnel_dest_group", + "delete_tunnel_dest_group", + "update_tunnel_dest_group", ) for method in methods: with pytest.raises(NotImplementedError): @@ -1983,8 +3458,61 @@ def test_identity_aware_proxy_admin_service_transport_channel_mtls_with_adc( assert transport.grpc_channel == mock_grpc_channel +def test_tunnel_dest_group_path(): + project = "squid" + location = "clam" + dest_group = "whelk" + expected = "projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}".format( + project=project, + location=location, + dest_group=dest_group, + ) + actual = IdentityAwareProxyAdminServiceClient.tunnel_dest_group_path( + project, location, dest_group + ) + assert expected == actual + + +def test_parse_tunnel_dest_group_path(): + expected = { + "project": "octopus", + "location": "oyster", + "dest_group": "nudibranch", + } + path = IdentityAwareProxyAdminServiceClient.tunnel_dest_group_path(**expected) + + # Check that the path construction is reversible. + actual = IdentityAwareProxyAdminServiceClient.parse_tunnel_dest_group_path(path) + assert expected == actual + + +def test_tunnel_location_path(): + project = "cuttlefish" + location = "mussel" + expected = "projects/{project}/iap_tunnel/locations/{location}".format( + project=project, + location=location, + ) + actual = IdentityAwareProxyAdminServiceClient.tunnel_location_path( + project, location + ) + assert expected == actual + + +def test_parse_tunnel_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = IdentityAwareProxyAdminServiceClient.tunnel_location_path(**expected) + + # Check that the path construction is reversible. + actual = IdentityAwareProxyAdminServiceClient.parse_tunnel_location_path(path) + assert expected == actual + + def test_common_billing_account_path(): - billing_account = "squid" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1996,7 +3524,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "clam", + "billing_account": "abalone", } path = IdentityAwareProxyAdminServiceClient.common_billing_account_path(**expected) @@ -2008,7 +3536,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "whelk" + folder = "squid" expected = "folders/{folder}".format( folder=folder, ) @@ -2018,7 +3546,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "octopus", + "folder": "clam", } path = IdentityAwareProxyAdminServiceClient.common_folder_path(**expected) @@ -2028,7 +3556,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "oyster" + organization = "whelk" expected = "organizations/{organization}".format( organization=organization, ) @@ -2038,7 +3566,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nudibranch", + "organization": "octopus", } path = IdentityAwareProxyAdminServiceClient.common_organization_path(**expected) @@ -2048,7 +3576,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "cuttlefish" + project = "oyster" expected = "projects/{project}".format( project=project, ) @@ -2058,7 +3586,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "mussel", + "project": "nudibranch", } path = IdentityAwareProxyAdminServiceClient.common_project_path(**expected) @@ -2068,8 +3596,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "winkle" - location = "nautilus" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -2082,8 +3610,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "scallop", - "location": "abalone", + "project": "winkle", + "location": "nautilus", } path = IdentityAwareProxyAdminServiceClient.common_location_path(**expected)