diff --git a/.flake8 b/.flake8 index 29227d4..2e43874 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..757c9dc 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000..311ebbb --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000..41bff0b --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e..6def37a 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb..238b87b 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a7..46d2371 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 29b79fa..93d9cfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [1.4.0](https://github.com/googleapis/python-iap/compare/v1.3.1...v1.4.0) (2022-05-19) + + +### Features + +* add ReauthSettings to the UpdateIapSettingsRequest ([36c1866](https://github.com/googleapis/python-iap/commit/36c1866e605e4e880e65eb44a7d4dc49389f92f3)) +* add the TunnelDestGroup-related methods and types ([#93](https://github.com/googleapis/python-iap/issues/93)) ([36c1866](https://github.com/googleapis/python-iap/commit/36c1866e605e4e880e65eb44a7d4dc49389f92f3)) +* AuditConfig for IAM v1 ([49dc9c7](https://github.com/googleapis/python-iap/commit/49dc9c7162e956c684892bdf866f20b47e3b27d2)) + + +### Bug Fixes + +* **deps:** require grpc-google-iam-v1 >=0.12.4 ([49dc9c7](https://github.com/googleapis/python-iap/commit/49dc9c7162e956c684892bdf866f20b47e3b27d2)) + ### [1.3.1](https://github.com/googleapis/python-iap/compare/v1.3.0...v1.3.1) (2022-03-05) diff --git a/docs/conf.py b/docs/conf.py index 1fe04ef..5449aab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-iap", "google-cloud-iap Documentation", [author], 1,) + ( + root_doc, + "google-cloud-iap", + "google-cloud-iap Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/docs/iap_v1/identity_aware_proxy_admin_service.rst b/docs/iap_v1/identity_aware_proxy_admin_service.rst index 1275baf..3098cf5 100644 --- a/docs/iap_v1/identity_aware_proxy_admin_service.rst +++ b/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/google/cloud/iap/__init__.py b/google/cloud/iap/__init__.py index 205c6c2..77b9746 100644 --- a/google/cloud/iap/__init__.py +++ b/google/cloud/iap/__init__.py @@ -14,42 +14,51 @@ # limitations under the License. # +from google.cloud.iap_v1.services.identity_aware_proxy_admin_service.async_client import ( + IdentityAwareProxyAdminServiceAsyncClient, +) from google.cloud.iap_v1.services.identity_aware_proxy_admin_service.client import ( IdentityAwareProxyAdminServiceClient, ) -from google.cloud.iap_v1.services.identity_aware_proxy_admin_service.async_client import ( - IdentityAwareProxyAdminServiceAsyncClient, +from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service.async_client import ( + IdentityAwareProxyOAuthServiceAsyncClient, ) from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service.client import ( IdentityAwareProxyOAuthServiceClient, ) -from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service.async_client import ( - IdentityAwareProxyOAuthServiceAsyncClient, +from google.cloud.iap_v1.types.service import ( + AccessDeniedPageSettings, + AccessSettings, + ApplicationSettings, + Brand, + 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, ) -from google.cloud.iap_v1.types.service import AccessDeniedPageSettings -from google.cloud.iap_v1.types.service import AccessSettings -from google.cloud.iap_v1.types.service import ApplicationSettings -from google.cloud.iap_v1.types.service import Brand -from google.cloud.iap_v1.types.service import CorsSettings -from google.cloud.iap_v1.types.service import CreateBrandRequest -from google.cloud.iap_v1.types.service import CreateIdentityAwareProxyClientRequest -from google.cloud.iap_v1.types.service import CsmSettings -from google.cloud.iap_v1.types.service import DeleteIdentityAwareProxyClientRequest -from google.cloud.iap_v1.types.service import GcipSettings -from google.cloud.iap_v1.types.service import GetBrandRequest -from google.cloud.iap_v1.types.service import GetIapSettingsRequest -from google.cloud.iap_v1.types.service import GetIdentityAwareProxyClientRequest -from google.cloud.iap_v1.types.service import IapSettings -from google.cloud.iap_v1.types.service import IdentityAwareProxyClient -from google.cloud.iap_v1.types.service import ListBrandsRequest -from google.cloud.iap_v1.types.service import ListBrandsResponse -from google.cloud.iap_v1.types.service import ListIdentityAwareProxyClientsRequest -from google.cloud.iap_v1.types.service import ListIdentityAwareProxyClientsResponse -from google.cloud.iap_v1.types.service import OAuthSettings -from google.cloud.iap_v1.types.service import ResetIdentityAwareProxyClientSecretRequest -from google.cloud.iap_v1.types.service import UpdateIapSettingsRequest - __all__ = ( "IdentityAwareProxyAdminServiceClient", "IdentityAwareProxyAdminServiceAsyncClient", @@ -62,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/google/cloud/iap_v1/__init__.py b/google/cloud/iap_v1/__init__.py index c136085..487d617 100644 --- a/google/cloud/iap_v1/__init__.py +++ b/google/cloud/iap_v1/__init__.py @@ -14,42 +14,47 @@ # limitations under the License. # -from .services.identity_aware_proxy_admin_service import ( - IdentityAwareProxyAdminServiceClient, -) from .services.identity_aware_proxy_admin_service import ( IdentityAwareProxyAdminServiceAsyncClient, + IdentityAwareProxyAdminServiceClient, ) from .services.identity_aware_proxy_o_auth_service import ( + IdentityAwareProxyOAuthServiceAsyncClient, IdentityAwareProxyOAuthServiceClient, ) -from .services.identity_aware_proxy_o_auth_service import ( - IdentityAwareProxyOAuthServiceAsyncClient, +from .types.service import ( + AccessDeniedPageSettings, + AccessSettings, + ApplicationSettings, + Brand, + 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, ) -from .types.service import AccessDeniedPageSettings -from .types.service import AccessSettings -from .types.service import ApplicationSettings -from .types.service import Brand -from .types.service import CorsSettings -from .types.service import CreateBrandRequest -from .types.service import CreateIdentityAwareProxyClientRequest -from .types.service import CsmSettings -from .types.service import DeleteIdentityAwareProxyClientRequest -from .types.service import GcipSettings -from .types.service import GetBrandRequest -from .types.service import GetIapSettingsRequest -from .types.service import GetIdentityAwareProxyClientRequest -from .types.service import IapSettings -from .types.service import IdentityAwareProxyClient -from .types.service import ListBrandsRequest -from .types.service import ListBrandsResponse -from .types.service import ListIdentityAwareProxyClientsRequest -from .types.service import ListIdentityAwareProxyClientsResponse -from .types.service import OAuthSettings -from .types.service import ResetIdentityAwareProxyClientSecretRequest -from .types.service import UpdateIapSettingsRequest - __all__ = ( "IdentityAwareProxyAdminServiceAsyncClient", "IdentityAwareProxyOAuthServiceAsyncClient", @@ -60,12 +65,15 @@ "CorsSettings", "CreateBrandRequest", "CreateIdentityAwareProxyClientRequest", + "CreateTunnelDestGroupRequest", "CsmSettings", "DeleteIdentityAwareProxyClientRequest", + "DeleteTunnelDestGroupRequest", "GcipSettings", "GetBrandRequest", "GetIapSettingsRequest", "GetIdentityAwareProxyClientRequest", + "GetTunnelDestGroupRequest", "IapSettings", "IdentityAwareProxyAdminServiceClient", "IdentityAwareProxyClient", @@ -74,7 +82,12 @@ "ListBrandsResponse", "ListIdentityAwareProxyClientsRequest", "ListIdentityAwareProxyClientsResponse", + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", "OAuthSettings", + "ReauthSettings", "ResetIdentityAwareProxyClientSecretRequest", + "TunnelDestGroup", "UpdateIapSettingsRequest", + "UpdateTunnelDestGroupRequest", ) diff --git a/google/cloud/iap_v1/gapic_metadata.json b/google/cloud/iap_v1/gapic_metadata.json index 8eb05c4..9f855f6 100644 --- a/google/cloud/iap_v1/gapic_metadata.json +++ b/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/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/__init__.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/__init__.py index 8aad0ae..01c544c 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/__init__.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import IdentityAwareProxyAdminServiceClient from .async_client import IdentityAwareProxyAdminServiceAsyncClient +from .client import IdentityAwareProxyAdminServiceClient __all__ = ( "IdentityAwareProxyAdminServiceClient", diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py index fbf3499..0c6fed3 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/async_client.py @@ -16,30 +16,34 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.iap_v1.types import service 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 from .transports.base import ( - IdentityAwareProxyAdminServiceTransport, DEFAULT_CLIENT_INFO, + IdentityAwareProxyAdminServiceTransport, ) from .transports.grpc_asyncio import IdentityAwareProxyAdminServiceGrpcAsyncIOTransport -from .client import IdentityAwareProxyAdminServiceClient class IdentityAwareProxyAdminServiceAsyncClient: @@ -50,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 ) @@ -224,22 +240,22 @@ async def set_iam_policy( information about managing access via IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = iap_v1.IdentityAwareProxyAdminServiceClient() + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -256,21 +272,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -285,17 +306,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -306,11 +327,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -334,7 +356,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -352,22 +379,22 @@ async def get_iam_policy( IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = iap_v1.IdentityAwareProxyAdminServiceClient() + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -384,21 +411,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -413,17 +445,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -434,11 +466,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -462,7 +495,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -480,23 +518,23 @@ async def test_iam_permissions( via IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = iap_v1.IdentityAwareProxyAdminServiceClient() + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) @@ -536,7 +574,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -552,14 +595,13 @@ async def get_iap_settings( r"""Gets the IAP settings on a particular IAP protected resource. - .. code-block:: python from google.cloud import iap_v1 - def sample_get_iap_settings(): + async def sample_get_iap_settings(): # Create a client - client = iap_v1.IdentityAwareProxyAdminServiceClient() + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) request = iap_v1.GetIapSettingsRequest( @@ -567,7 +609,7 @@ def sample_get_iap_settings(): ) # Make the request - response = client.get_iap_settings(request=request) + response = await client.get_iap_settings(request=request) # Handle the response print(response) @@ -603,7 +645,12 @@ def sample_get_iap_settings(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -619,14 +666,13 @@ async def update_iap_settings( r"""Updates the IAP settings on a particular IAP protected resource. It replaces all fields unless the ``update_mask`` is set. - .. code-block:: python from google.cloud import iap_v1 - def sample_update_iap_settings(): + async def sample_update_iap_settings(): # Create a client - client = iap_v1.IdentityAwareProxyAdminServiceClient() + client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) iap_settings = iap_v1.IapSettings() @@ -637,7 +683,7 @@ def sample_update_iap_settings(): ) # Make the request - response = client.update_iap_settings(request=request) + response = await client.update_iap_settings(request=request) # Handle the response print(response) @@ -676,7 +722,533 @@ def sample_update_iap_settings(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + 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 @@ -690,7 +1262,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py index 186b24c..4589ab8 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/client.py @@ -16,30 +16,34 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.iap_v1.types import service 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 ( - IdentityAwareProxyAdminServiceTransport, DEFAULT_CLIENT_INFO, + IdentityAwareProxyAdminServiceTransport, ) from .transports.grpc import IdentityAwareProxyAdminServiceGrpcTransport from .transports.grpc_asyncio import IdentityAwareProxyAdminServiceGrpcAsyncIOTransport @@ -62,7 +66,8 @@ class IdentityAwareProxyAdminServiceClientMeta(type): ] = IdentityAwareProxyAdminServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[IdentityAwareProxyAdminServiceTransport]: """Returns an appropriate transport class. @@ -170,7 +175,50 @@ def transport(self) -> IdentityAwareProxyAdminServiceTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + 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, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -183,9 +231,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -194,9 +246,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -205,9 +261,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -216,10 +276,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -406,17 +470,17 @@ def set_iam_policy( information about managing access via IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -438,21 +502,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -467,17 +536,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -488,11 +557,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -515,7 +585,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -533,17 +608,17 @@ def get_iam_policy( IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -565,21 +640,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -594,17 +674,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -615,11 +695,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -642,7 +723,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -660,17 +746,17 @@ def test_iam_permissions( via IAP can be found at: https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - .. code-block:: python from google.cloud import iap_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -715,7 +801,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -731,7 +822,6 @@ def get_iap_settings( r"""Gets the IAP settings on a particular IAP protected resource. - .. code-block:: python from google.cloud import iap_v1 @@ -783,7 +873,12 @@ def sample_get_iap_settings(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -799,7 +894,6 @@ def update_iap_settings( r"""Updates the IAP settings on a particular IAP protected resource. It replaces all fields unless the ``update_mask`` is set. - .. code-block:: python from google.cloud import iap_v1 @@ -857,7 +951,533 @@ def sample_update_iap_settings(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + 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 @@ -878,7 +1498,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/pagers.py new file mode 100644 index 0000000..55d09d6 --- /dev/null +++ b/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/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/__init__.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/__init__.py index db4da2a..0d37784 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/__init__.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import IdentityAwareProxyAdminServiceGrpcTransport from .grpc_asyncio import IdentityAwareProxyAdminServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py index b130201..51c9d94 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/base.py @@ -15,23 +15,26 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +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 -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -80,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -121,10 +125,14 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=None, client_info=client_info, + self.set_iam_policy, + default_timeout=None, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( - self.get_iam_policy, default_timeout=None, client_info=client_info, + self.get_iam_policy, + default_timeout=None, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, @@ -132,19 +140,48 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.get_iap_settings: gapic_v1.method.wrap_method( - self.get_iap_settings, default_timeout=None, client_info=client_info, + self.get_iap_settings, + default_timeout=None, + client_info=client_info, ), self.update_iap_settings: gapic_v1.method.wrap_method( - self.update_iap_settings, default_timeout=None, client_info=client_info, + self.update_iap_settings, + 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): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -196,5 +233,57 @@ 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() + __all__ = ("IdentityAwareProxyAdminServiceTransport",) diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py index ef2c057..1651003 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc.py @@ -13,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore 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 -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from .base import IdentityAwareProxyAdminServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IdentityAwareProxyAdminServiceTransport class IdentityAwareProxyAdminServiceGrpcTransport( @@ -228,8 +228,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -376,8 +375,146 @@ 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() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("IdentityAwareProxyAdminServiceGrpcTransport",) diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py index 4f971de..2d4cf53 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_admin_service/transports/grpc_asyncio.py @@ -13,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore 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 from google.cloud.iap_v1.types import service -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from .base import IdentityAwareProxyAdminServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IdentityAwareProxyAdminServiceTransport from .grpc import IdentityAwareProxyAdminServiceGrpcTransport @@ -378,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/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/__init__.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/__init__.py index 4d9a99a..7cdc6b2 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/__init__.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import IdentityAwareProxyOAuthServiceClient from .async_client import IdentityAwareProxyOAuthServiceAsyncClient +from .client import IdentityAwareProxyOAuthServiceClient __all__ = ( "IdentityAwareProxyOAuthServiceClient", diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py index bdaf67c..4b4b7d1 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/async_client.py @@ -16,15 +16,15 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,12 +33,13 @@ from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import pagers from google.cloud.iap_v1.types import service + +from .client import IdentityAwareProxyOAuthServiceClient from .transports.base import ( - IdentityAwareProxyOAuthServiceTransport, DEFAULT_CLIENT_INFO, + IdentityAwareProxyOAuthServiceTransport, ) from .transports.grpc_asyncio import IdentityAwareProxyOAuthServiceGrpcAsyncIOTransport -from .client import IdentityAwareProxyOAuthServiceClient class IdentityAwareProxyOAuthServiceAsyncClient: @@ -227,9 +228,9 @@ async def list_brands( from google.cloud import iap_v1 - def sample_list_brands(): + async def sample_list_brands(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.ListBrandsRequest( @@ -237,7 +238,7 @@ def sample_list_brands(): ) # Make the request - response = client.list_brands(request=request) + response = await client.list_brands(request=request) # Handle the response print(response) @@ -273,7 +274,12 @@ def sample_list_brands(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -289,22 +295,21 @@ 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 from google.cloud import iap_v1 - def sample_create_brand(): + async def sample_create_brand(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.CreateBrandRequest( @@ -312,7 +317,7 @@ def sample_create_brand(): ) # Make the request - response = client.create_brand(request=request) + response = await client.create_brand(request=request) # Handle the response print(response) @@ -351,7 +356,12 @@ def sample_create_brand(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -370,9 +380,9 @@ async def get_brand( from google.cloud import iap_v1 - def sample_get_brand(): + async def sample_get_brand(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.GetBrandRequest( @@ -380,7 +390,7 @@ def sample_get_brand(): ) # Make the request - response = client.get_brand(request=request) + response = await client.get_brand(request=request) # Handle the response print(response) @@ -419,7 +429,12 @@ def sample_get_brand(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -437,14 +452,13 @@ async def create_identity_aware_proxy_client( the project exists and that it is set for internal-only use. - .. code-block:: python from google.cloud import iap_v1 - def sample_create_identity_aware_proxy_client(): + async def sample_create_identity_aware_proxy_client(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.CreateIdentityAwareProxyClientRequest( @@ -452,7 +466,7 @@ def sample_create_identity_aware_proxy_client(): ) # Make the request - response = client.create_identity_aware_proxy_client(request=request) + response = await client.create_identity_aware_proxy_client(request=request) # Handle the response print(response) @@ -491,7 +505,12 @@ def sample_create_identity_aware_proxy_client(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -510,9 +529,9 @@ async def list_identity_aware_proxy_clients( from google.cloud import iap_v1 - def sample_list_identity_aware_proxy_clients(): + async def sample_list_identity_aware_proxy_clients(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.ListIdentityAwareProxyClientsRequest( @@ -523,7 +542,7 @@ def sample_list_identity_aware_proxy_clients(): page_result = client.list_identity_aware_proxy_clients(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -563,12 +582,20 @@ def sample_list_identity_aware_proxy_clients(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListIdentityAwareProxyClientsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -585,14 +612,13 @@ async def get_identity_aware_proxy_client( r"""Retrieves an Identity Aware Proxy (IAP) OAuth client. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 - def sample_get_identity_aware_proxy_client(): + async def sample_get_identity_aware_proxy_client(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.GetIdentityAwareProxyClientRequest( @@ -600,7 +626,7 @@ def sample_get_identity_aware_proxy_client(): ) # Make the request - response = client.get_identity_aware_proxy_client(request=request) + response = await client.get_identity_aware_proxy_client(request=request) # Handle the response print(response) @@ -639,7 +665,12 @@ def sample_get_identity_aware_proxy_client(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -656,14 +687,13 @@ async def reset_identity_aware_proxy_client_secret( secret. Useful if the secret was compromised. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 - def sample_reset_identity_aware_proxy_client_secret(): + async def sample_reset_identity_aware_proxy_client_secret(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.ResetIdentityAwareProxyClientSecretRequest( @@ -671,7 +701,7 @@ def sample_reset_identity_aware_proxy_client_secret(): ) # Make the request - response = client.reset_identity_aware_proxy_client_secret(request=request) + response = await client.reset_identity_aware_proxy_client_secret(request=request) # Handle the response print(response) @@ -710,7 +740,12 @@ def sample_reset_identity_aware_proxy_client_secret(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -728,14 +763,13 @@ async def delete_identity_aware_proxy_client( number of clients in a given project, and cleaning up after tests. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 - def sample_delete_identity_aware_proxy_client(): + async def sample_delete_identity_aware_proxy_client(): # Create a client - client = iap_v1.IdentityAwareProxyOAuthServiceClient() + client = iap_v1.IdentityAwareProxyOAuthServiceAsyncClient() # Initialize request argument(s) request = iap_v1.DeleteIdentityAwareProxyClientRequest( @@ -743,7 +777,7 @@ def sample_delete_identity_aware_proxy_client(): ) # Make the request - client.delete_identity_aware_proxy_client(request=request) + await client.delete_identity_aware_proxy_client(request=request) Args: request (Union[google.cloud.iap_v1.types.DeleteIdentityAwareProxyClientRequest, dict]): @@ -774,7 +808,10 @@ def sample_delete_identity_aware_proxy_client(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): @@ -786,7 +823,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py index 5ff545a..af44957 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/client.py @@ -16,18 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,9 +36,10 @@ from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import pagers from google.cloud.iap_v1.types import service + from .transports.base import ( - IdentityAwareProxyOAuthServiceTransport, DEFAULT_CLIENT_INFO, + IdentityAwareProxyOAuthServiceTransport, ) from .transports.grpc import IdentityAwareProxyOAuthServiceGrpcTransport from .transports.grpc_asyncio import IdentityAwareProxyOAuthServiceGrpcAsyncIOTransport @@ -61,7 +62,8 @@ class IdentityAwareProxyOAuthServiceClientMeta(type): ] = IdentityAwareProxyOAuthServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[IdentityAwareProxyOAuthServiceTransport]: """Returns an appropriate transport class. @@ -172,7 +174,9 @@ def transport(self) -> IdentityAwareProxyOAuthServiceTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -185,9 +189,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -196,9 +204,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -207,9 +219,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -218,10 +234,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -456,7 +476,12 @@ def sample_list_brands(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -472,14 +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 @@ -535,7 +559,12 @@ def sample_create_brand(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -604,7 +633,12 @@ def sample_get_brand(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -622,7 +656,6 @@ def create_identity_aware_proxy_client( the project exists and that it is set for internal-only use. - .. code-block:: python from google.cloud import iap_v1 @@ -679,7 +712,12 @@ def sample_create_identity_aware_proxy_client(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -754,12 +792,20 @@ def sample_list_identity_aware_proxy_clients(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListIdentityAwareProxyClientsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -776,7 +822,6 @@ def get_identity_aware_proxy_client( r"""Retrieves an Identity Aware Proxy (IAP) OAuth client. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 @@ -833,7 +878,12 @@ def sample_get_identity_aware_proxy_client(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -850,7 +900,6 @@ def reset_identity_aware_proxy_client_secret( secret. Useful if the secret was compromised. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 @@ -907,7 +956,12 @@ def sample_reset_identity_aware_proxy_client_secret(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -925,7 +979,6 @@ def delete_identity_aware_proxy_client( number of clients in a given project, and cleaning up after tests. Requires that the client is owned by IAP. - .. code-block:: python from google.cloud import iap_v1 @@ -974,7 +1027,10 @@ def sample_delete_identity_aware_proxy_client(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): @@ -993,7 +1049,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/pagers.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/pagers.py index 06a1a74..c059aa8 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/pagers.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/pagers.py @@ -18,10 +18,10 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) from google.cloud.iap_v1.types import service diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/__init__.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/__init__.py index 2ccc613..eb0b140 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/__init__.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import IdentityAwareProxyOAuthServiceGrpcTransport from .grpc_asyncio import IdentityAwareProxyOAuthServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/base.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/base.py index 8db4945..eb0e766 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/base.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/base.py @@ -15,22 +15,24 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # 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 -from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-iap",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-iap", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -79,6 +81,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -120,13 +123,19 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_brands: gapic_v1.method.wrap_method( - self.list_brands, default_timeout=None, client_info=client_info, + self.list_brands, + default_timeout=None, + client_info=client_info, ), self.create_brand: gapic_v1.method.wrap_method( - self.create_brand, default_timeout=None, client_info=client_info, + self.create_brand, + default_timeout=None, + client_info=client_info, ), self.get_brand: gapic_v1.method.wrap_method( - self.get_brand, default_timeout=None, client_info=client_info, + self.get_brand, + default_timeout=None, + client_info=client_info, ), self.create_identity_aware_proxy_client: gapic_v1.method.wrap_method( self.create_identity_aware_proxy_client, @@ -158,9 +167,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -246,5 +255,9 @@ def delete_identity_aware_proxy_client( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("IdentityAwareProxyOAuthServiceTransport",) diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py index cbab59e..1fe3510 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc.py @@ -13,20 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from google.cloud.iap_v1.types import service -from google.protobuf import empty_pb2 # type: ignore -from .base import IdentityAwareProxyOAuthServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IdentityAwareProxyOAuthServiceTransport class IdentityAwareProxyOAuthServiceGrpcTransport( @@ -229,8 +228,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -266,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], @@ -484,5 +482,9 @@ def delete_identity_aware_proxy_client( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("IdentityAwareProxyOAuthServiceGrpcTransport",) diff --git a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py index d1a35a5..491dcc8 100644 --- a/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py +++ b/google/cloud/iap_v1/services/identity_aware_proxy_o_auth_service/transports/grpc_asyncio.py @@ -13,20 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.iap_v1.types import service -from google.protobuf import empty_pb2 # type: ignore -from .base import IdentityAwareProxyOAuthServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IdentityAwareProxyOAuthServiceTransport from .grpc import IdentityAwareProxyOAuthServiceGrpcTransport @@ -270,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/google/cloud/iap_v1/types/__init__.py b/google/cloud/iap_v1/types/__init__.py index 09bcd32..1a7a56e 100644 --- a/google/cloud/iap_v1/types/__init__.py +++ b/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/google/cloud/iap_v1/types/service.py b/google/cloud/iap_v1/types/service.py index 7666fd5..c9d9e31 100644 --- a/google/cloud/iap_v1/types/service.py +++ b/google/cloud/iap_v1/types/service.py @@ -13,15 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - +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 __protobuf__ = proto.module( package="google.cloud.iap.v1", manifest={ + "ListTunnelDestGroupsRequest", + "ListTunnelDestGroupsResponse", + "CreateTunnelDestGroupRequest", + "GetTunnelDestGroupRequest", + "DeleteTunnelDestGroupRequest", + "UpdateTunnelDestGroupRequest", + "TunnelDestGroup", "GetIapSettingsRequest", "UpdateIapSettingsRequest", "IapSettings", @@ -29,6 +35,7 @@ "GcipSettings", "CorsSettings", "OAuthSettings", + "ReauthSettings", "ApplicationSettings", "CsmSettings", "AccessDeniedPageSettings", @@ -48,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. @@ -58,7 +253,10 @@ class GetIapSettingsRequest(proto.Message): permission for the associated resource. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateIapSettingsRequest(proto.Message): @@ -76,9 +274,15 @@ class UpdateIapSettingsRequest(proto.Message): https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask """ - iap_settings = proto.Field(proto.MESSAGE, number=1, message="IapSettings",) + iap_settings = proto.Field( + proto.MESSAGE, + number=1, + message="IapSettings", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -97,10 +301,19 @@ class IapSettings(proto.Message): settings in IAP """ - name = proto.Field(proto.STRING, number=1,) - access_settings = proto.Field(proto.MESSAGE, number=5, message="AccessSettings",) + name = proto.Field( + proto.STRING, + number=1, + ) + access_settings = proto.Field( + proto.MESSAGE, + number=5, + message="AccessSettings", + ) application_settings = proto.Field( - proto.MESSAGE, number=6, message="ApplicationSettings", + proto.MESSAGE, + number=6, + message="ApplicationSettings", ) @@ -116,11 +329,31 @@ 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(proto.MESSAGE, number=1, message="GcipSettings",) - cors_settings = proto.Field(proto.MESSAGE, number=2, message="CorsSettings",) - oauth_settings = proto.Field(proto.MESSAGE, number=3, message="OAuthSettings",) + gcip_settings = proto.Field( + proto.MESSAGE, + number=1, + message="GcipSettings", + ) + cors_settings = proto.Field( + proto.MESSAGE, + number=2, + message="CorsSettings", + ) + oauth_settings = proto.Field( + proto.MESSAGE, + number=3, + message="OAuthSettings", + ) + reauth_settings = proto.Field( + proto.MESSAGE, + number=6, + message="ReauthSettings", + ) class GcipSettings(proto.Message): @@ -143,9 +376,14 @@ class GcipSettings(proto.Message): level. """ - tenant_ids = proto.RepeatedField(proto.STRING, number=1,) + tenant_ids = proto.RepeatedField( + proto.STRING, + number=1, + ) login_page_uri = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.StringValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.StringValue, ) @@ -162,7 +400,9 @@ class CorsSettings(proto.Message): """ allow_http_options = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.BoolValue, ) @@ -181,7 +421,57 @@ class OAuthSettings(proto.Message): is managed by IAM policies. """ - login_hint = proto.Field(proto.MESSAGE, number=2, message=wrappers_pb2.StringValue,) + login_hint = proto.Field( + proto.MESSAGE, + number=2, + message=wrappers_pb2.StringValue, + ) + + +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): @@ -199,12 +489,20 @@ class ApplicationSettings(proto.Message): but will be ignored at runtime if invalid. """ - csm_settings = proto.Field(proto.MESSAGE, number=1, message="CsmSettings",) + csm_settings = proto.Field( + proto.MESSAGE, + number=1, + message="CsmSettings", + ) access_denied_page_settings = proto.Field( - proto.MESSAGE, number=2, message="AccessDeniedPageSettings", + proto.MESSAGE, + number=2, + message="AccessDeniedPageSettings", ) cookie_domain = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.StringValue, + proto.MESSAGE, + number=3, + message=wrappers_pb2.StringValue, ) @@ -222,7 +520,9 @@ class CsmSettings(proto.Message): """ rctoken_aud = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.StringValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.StringValue, ) @@ -242,10 +542,14 @@ class AccessDeniedPageSettings(proto.Message): """ access_denied_page_uri = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.StringValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.StringValue, ) generate_troubleshooting_uri = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.BoolValue, ) @@ -258,7 +562,10 @@ class ListBrandsRequest(proto.Message): projects/{project_number/id}. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) class ListBrandsResponse(proto.Message): @@ -269,7 +576,11 @@ class ListBrandsResponse(proto.Message): Brands existing in the project. """ - brands = proto.RepeatedField(proto.MESSAGE, number=1, message="Brand",) + brands = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Brand", + ) class CreateBrandRequest(proto.Message): @@ -284,8 +595,15 @@ class CreateBrandRequest(proto.Message): Required. The brand to be created. """ - parent = proto.Field(proto.STRING, number=1,) - brand = proto.Field(proto.MESSAGE, number=2, message="Brand",) + parent = proto.Field( + proto.STRING, + number=1, + ) + brand = proto.Field( + proto.MESSAGE, + number=2, + message="Brand", + ) class GetBrandRequest(proto.Message): @@ -297,7 +615,10 @@ class GetBrandRequest(proto.Message): format: projects/{project_number/id}/brands/{brand}. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListIdentityAwareProxyClientsRequest(proto.Message): @@ -323,9 +644,18 @@ class ListIdentityAwareProxyClientsRequest(proto.Message): 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,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListIdentityAwareProxyClientsResponse(proto.Message): @@ -345,9 +675,14 @@ def raw_page(self): return self identity_aware_proxy_clients = proto.RepeatedField( - proto.MESSAGE, number=1, message="IdentityAwareProxyClient", + proto.MESSAGE, + number=1, + message="IdentityAwareProxyClient", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class CreateIdentityAwareProxyClientRequest(proto.Message): @@ -363,9 +698,14 @@ class CreateIdentityAwareProxyClientRequest(proto.Message): created. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) identity_aware_proxy_client = proto.Field( - proto.MESSAGE, number=2, message="IdentityAwareProxyClient", + proto.MESSAGE, + number=2, + message="IdentityAwareProxyClient", ) @@ -379,7 +719,10 @@ class GetIdentityAwareProxyClientRequest(proto.Message): projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_id}. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ResetIdentityAwareProxyClientSecretRequest(proto.Message): @@ -392,7 +735,10 @@ class ResetIdentityAwareProxyClientSecretRequest(proto.Message): projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_id}. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DeleteIdentityAwareProxyClientRequest(proto.Message): @@ -405,7 +751,10 @@ class DeleteIdentityAwareProxyClientRequest(proto.Message): projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_id}. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class Brand(proto.Message): @@ -431,10 +780,22 @@ class Brand(proto.Message): organization only. """ - name = proto.Field(proto.STRING, number=1,) - support_email = proto.Field(proto.STRING, number=2,) - application_title = proto.Field(proto.STRING, number=3,) - org_internal_only = proto.Field(proto.BOOL, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + support_email = proto.Field( + proto.STRING, + number=2, + ) + application_title = proto.Field( + proto.STRING, + number=3, + ) + org_internal_only = proto.Field( + proto.BOOL, + number=4, + ) class IdentityAwareProxyClient(proto.Message): @@ -453,9 +814,18 @@ class IdentityAwareProxyClient(proto.Message): client. """ - name = proto.Field(proto.STRING, number=1,) - secret = proto.Field(proto.STRING, number=2,) - display_name = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + secret = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..7c1742d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,19 +17,45 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +83,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +95,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +127,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +185,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +236,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_async.py new file mode 100644 index 0000000..bb1cf07 --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_create_tunnel_dest_group_sync.py new file mode 100644 index 0000000..e48765c --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_async.py new file mode 100644 index 0000000..cdd5ca7 --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_delete_tunnel_dest_group_sync.py new file mode 100644 index 0000000..3122a18 --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py index 681c7e3..82b43ec 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_async] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py index a4f0419..baca476 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_sync] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_async.py new file mode 100644 index 0000000..4ecfe6d --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_get_tunnel_dest_group_sync.py new file mode 100644 index 0000000..a08b2e7 --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py new file mode 100644 index 0000000..a40f93f --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py new file mode 100644 index 0000000..2805b3e --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py index 4e3a571..aab5947 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_async] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py index 3f1033c..8530b6a 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_sync] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py index 65ac438..f8a7260 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_async] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = iap_v1.IdentityAwareProxyAdminServiceAsyncClient() # Initialize request argument(s) - request = iap_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py index 905047c..05502cc 100644 --- a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py +++ b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_sync] from google.cloud import iap_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = iap_v1.IdentityAwareProxyAdminServiceClient() # Initialize request argument(s) - request = iap_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_async.py new file mode 100644 index 0000000..89e71d2 --- /dev/null +++ b/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/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py b/samples/generated_samples/iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py new file mode 100644 index 0000000..fd209e8 --- /dev/null +++ b/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/samples/generated_samples/snippet_metadata_iap_v1.json b/samples/generated_samples/snippet_metadata_iap_v1.json index 09cc478..d439c43 100644 --- a/samples/generated_samples/snippet_metadata_iap_v1.json +++ b/samples/generated_samples/snippet_metadata_iap_v1.json @@ -1,17 +1,543 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.iap.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "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": "GetIamPolicy" + "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": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.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_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, @@ -43,19 +569,51 @@ "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": "GetIamPolicy" - } + "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" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iam_policy_sync.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_sync", + "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, @@ -87,20 +645,136 @@ "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": "GetIapSettings" + "shortName": "GetTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "get_tunnel_dest_group" + }, + "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_GetTunnelDestGroup_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_tunnel_dest_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.get_tunnel_dest_group", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.GetTunnelDestGroup", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "GetTunnelDestGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetTunnelDestGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.types.TunnelDestGroup", + "shortName": "get_tunnel_dest_group" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_async.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_async", + "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_GetTunnelDestGroup_sync", "segments": [ { "end": 44, @@ -128,165 +802,531 @@ "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_get_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.list_tunnel_dest_groups", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.ListTunnelDestGroups", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "ListTunnelDestGroups" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListTunnelDestGroupsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsAsyncPager", + "shortName": "list_tunnel_dest_groups" + }, + "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_ListTunnelDestGroups_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "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": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.list_tunnel_dest_groups", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.ListTunnelDestGroups", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "ListTunnelDestGroups" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListTunnelDestGroupsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.pagers.ListTunnelDestGroupsPager", + "shortName": "list_tunnel_dest_groups" + }, + "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_ListTunnelDestGroups_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "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": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_list_tunnel_dest_groups_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.set_iam_policy", + "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.SetIamPolicy", + "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", + "shortName": "IdentityAwareProxyAdminService" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "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": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_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_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.set_iam_policy", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.SetIamPolicy", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "GetIapSettings" - } + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "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": "set_iam_policy" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_get_iap_settings_sync.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_sync", + "description": "Sample for SetIamPolicy", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.test_iam_permissions", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.TestIamPermissions", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "SetIamPolicy" - } + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_async.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_async", + "description": "Sample for TestIamPermissions", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_async", "segments": [ { - "end": 44, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.test_iam_permissions", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.TestIamPermissions", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "SetIamPolicy" - } + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_set_iam_policy_sync.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_sync", + "description": "Sample for TestIamPermissions", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_sync", "segments": [ { - "end": 44, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient", + "shortName": "IdentityAwareProxyAdminServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceAsyncClient.update_iap_settings", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.UpdateIapSettings", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "TestIamPermissions" - } + "shortName": "UpdateIapSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.UpdateIapSettingsRequest" + }, + { + "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": "update_iap_settings" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_async.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_async", + "description": "Sample for UpdateIapSettings", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_async", "segments": [ { - "end": 45, + "end": 47, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 47, "start": 27, "type": "SHORT" }, @@ -296,41 +1336,73 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 39, + "end": 41, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 44, + "start": 42, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 48, + "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient", + "shortName": "IdentityAwareProxyAdminServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyAdminServiceClient.update_iap_settings", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService.UpdateIapSettings", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyAdminService", "shortName": "IdentityAwareProxyAdminService" }, - "shortName": "TestIamPermissions" - } + "shortName": "UpdateIapSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.UpdateIapSettingsRequest" + }, + { + "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": "update_iap_settings" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_test_iam_permissions_sync.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_sync", + "description": "Sample for UpdateIapSettings", + "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_sync", "segments": [ { - "end": 45, + "end": 47, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 47, "start": 27, "type": "SHORT" }, @@ -340,34 +1412,74 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 39, + "end": 41, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 44, + "start": 42, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 48, + "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "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": "UpdateIapSettings" - } + "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" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_async.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_async", + "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, @@ -399,19 +1511,59 @@ "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": "UpdateIapSettings" - } + "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" }, - "file": "iap_v1_generated_identity_aware_proxy_admin_service_update_iap_settings_sync.py", - "regionTag": "iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_sync", + "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, @@ -443,19 +1595,51 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_admin_service_update_tunnel_dest_group_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.create_brand", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.CreateBrand", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "CreateBrand" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateBrandRequest" + }, + { + "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.Brand", + "shortName": "create_brand" }, + "description": "Sample for CreateBrand", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_brand_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_CreateBrand_async", "segments": [ { @@ -488,18 +1672,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_brand_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.create_brand", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.CreateBrand", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "CreateBrand" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateBrandRequest" + }, + { + "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.Brand", + "shortName": "create_brand" }, + "description": "Sample for CreateBrand", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_brand_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_CreateBrand_sync", "segments": [ { @@ -532,19 +1748,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_brand_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.create_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.CreateIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "CreateIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateIdentityAwareProxyClientRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "create_identity_aware_proxy_client" }, + "description": "Sample for CreateIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_identity_aware_proxy_client_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_CreateIdentityAwareProxyClient_async", "segments": [ { @@ -577,18 +1825,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_identity_aware_proxy_client_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.create_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.CreateIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "CreateIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.CreateIdentityAwareProxyClientRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "create_identity_aware_proxy_client" }, + "description": "Sample for CreateIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_identity_aware_proxy_client_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_CreateIdentityAwareProxyClient_sync", "segments": [ { @@ -621,19 +1901,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_create_identity_aware_proxy_client_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.delete_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.DeleteIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "DeleteIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.DeleteIdentityAwareProxyClientRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_identity_aware_proxy_client" }, + "description": "Sample for DeleteIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_delete_identity_aware_proxy_client_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_DeleteIdentityAwareProxyClient_async", "segments": [ { @@ -664,18 +1975,49 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_delete_identity_aware_proxy_client_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.delete_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.DeleteIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "DeleteIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.DeleteIdentityAwareProxyClientRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_identity_aware_proxy_client" }, + "description": "Sample for DeleteIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_delete_identity_aware_proxy_client_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_DeleteIdentityAwareProxyClient_sync", "segments": [ { @@ -706,19 +2048,51 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_delete_identity_aware_proxy_client_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.get_brand", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.GetBrand", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "GetBrand" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetBrandRequest" + }, + { + "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.Brand", + "shortName": "get_brand" }, + "description": "Sample for GetBrand", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_brand_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_GetBrand_async", "segments": [ { @@ -751,18 +2125,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_brand_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.get_brand", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.GetBrand", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "GetBrand" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetBrandRequest" + }, + { + "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.Brand", + "shortName": "get_brand" }, + "description": "Sample for GetBrand", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_brand_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_GetBrand_sync", "segments": [ { @@ -795,19 +2201,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_brand_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.get_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.GetIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "GetIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetIdentityAwareProxyClientRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "get_identity_aware_proxy_client" }, + "description": "Sample for GetIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_identity_aware_proxy_client_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_GetIdentityAwareProxyClient_async", "segments": [ { @@ -840,18 +2278,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_identity_aware_proxy_client_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.get_identity_aware_proxy_client", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.GetIdentityAwareProxyClient", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "GetIdentityAwareProxyClient" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.GetIdentityAwareProxyClientRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "get_identity_aware_proxy_client" }, + "description": "Sample for GetIdentityAwareProxyClient", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_identity_aware_proxy_client_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_GetIdentityAwareProxyClient_sync", "segments": [ { @@ -884,19 +2354,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_get_identity_aware_proxy_client_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.list_brands", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ListBrands", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ListBrands" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListBrandsRequest" + }, + { + "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.ListBrandsResponse", + "shortName": "list_brands" }, + "description": "Sample for ListBrands", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_brands_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ListBrands_async", "segments": [ { @@ -929,18 +2431,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_brands_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.list_brands", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ListBrands", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ListBrands" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListBrandsRequest" + }, + { + "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.ListBrandsResponse", + "shortName": "list_brands" }, + "description": "Sample for ListBrands", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_brands_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ListBrands_sync", "segments": [ { @@ -973,19 +2507,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_brands_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.list_identity_aware_proxy_clients", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ListIdentityAwareProxyClients", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ListIdentityAwareProxyClients" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListIdentityAwareProxyClientsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service.pagers.ListIdentityAwareProxyClientsAsyncPager", + "shortName": "list_identity_aware_proxy_clients" }, + "description": "Sample for ListIdentityAwareProxyClients", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_identity_aware_proxy_clients_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ListIdentityAwareProxyClients_async", "segments": [ { @@ -1018,18 +2584,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_identity_aware_proxy_clients_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.list_identity_aware_proxy_clients", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ListIdentityAwareProxyClients", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ListIdentityAwareProxyClients" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ListIdentityAwareProxyClientsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service.pagers.ListIdentityAwareProxyClientsPager", + "shortName": "list_identity_aware_proxy_clients" }, + "description": "Sample for ListIdentityAwareProxyClients", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_identity_aware_proxy_clients_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ListIdentityAwareProxyClients_sync", "segments": [ { @@ -1062,19 +2660,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_list_identity_aware_proxy_clients_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient", + "shortName": "IdentityAwareProxyOAuthServiceAsyncClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceAsyncClient.reset_identity_aware_proxy_client_secret", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ResetIdentityAwareProxyClientSecret", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ResetIdentityAwareProxyClientSecret" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ResetIdentityAwareProxyClientSecretRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "reset_identity_aware_proxy_client_secret" }, + "description": "Sample for ResetIdentityAwareProxyClientSecret", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_reset_identity_aware_proxy_client_secret_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ResetIdentityAwareProxyClientSecret_async", "segments": [ { @@ -1107,18 +2737,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_reset_identity_aware_proxy_client_secret_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient", + "shortName": "IdentityAwareProxyOAuthServiceClient" + }, + "fullName": "google.cloud.iap_v1.IdentityAwareProxyOAuthServiceClient.reset_identity_aware_proxy_client_secret", "method": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService.ResetIdentityAwareProxyClientSecret", "service": { + "fullName": "google.cloud.iap.v1.IdentityAwareProxyOAuthService", "shortName": "IdentityAwareProxyOAuthService" }, "shortName": "ResetIdentityAwareProxyClientSecret" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.iap_v1.types.ResetIdentityAwareProxyClientSecretRequest" + }, + { + "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.IdentityAwareProxyClient", + "shortName": "reset_identity_aware_proxy_client_secret" }, + "description": "Sample for ResetIdentityAwareProxyClientSecret", "file": "iap_v1_generated_identity_aware_proxy_o_auth_service_reset_identity_aware_proxy_client_secret_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "iap_v1_generated_IdentityAwareProxyOAuthService_ResetIdentityAwareProxyClientSecret_sync", "segments": [ { @@ -1151,7 +2813,8 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "iap_v1_generated_identity_aware_proxy_o_auth_service_reset_identity_aware_proxy_client_secret_sync.py" } ] } diff --git a/scripts/fixup_iap_v1_keywords.py b/scripts/fixup_iap_v1_keywords.py index 2b3dc85..7359ed1 100644 --- a/scripts/fixup_iap_v1_keywords.py +++ b/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', ), + '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/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e..91b5967 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index 9a1ded1..17e22c8 100644 --- a/setup.py +++ b/setup.py @@ -19,10 +19,9 @@ import setuptools - name = "google-cloud-iap" description = "Identity-Aware Proxy API client library" -version = "1.3.1" +version = "1.4.0" release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-iap" dependencies = [ @@ -31,7 +30,7 @@ # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", "proto-plus >= 1.15.0", - "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 97384ff..5a93d69 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,4 +6,4 @@ # Then this file should have google-cloud-foo==1.14.0 google-api-core==1.31.5 proto-plus==1.15.0 -grpc-google-iam-v1==0.12.3 +grpc-google-iam-v1==0.12.4 diff --git a/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py b/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py index c44016a..b97c34a 100644 --- a/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py +++ b/tests/unit/gapic/iap_v1/test_identity_aware_proxy_admin_service.py @@ -13,40 +13,36 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import ( - IdentityAwareProxyAdminServiceAsyncClient, -) -from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import ( - IdentityAwareProxyAdminServiceClient, -) -from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import transports -from google.cloud.iap_v1.types import service from google.iam.v1 import iam_policy_pb2 # type: ignore 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 -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.iap_v1.services.identity_aware_proxy_admin_service import ( + IdentityAwareProxyAdminServiceAsyncClient, + IdentityAwareProxyAdminServiceClient, + pagers, + transports, +) +from google.cloud.iap_v1.types import service def client_cert_source_callback(): @@ -101,11 +97,14 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", - [IdentityAwareProxyAdminServiceClient, IdentityAwareProxyAdminServiceAsyncClient,], + "client_class,transport_name", + [ + (IdentityAwareProxyAdminServiceClient, "grpc"), + (IdentityAwareProxyAdminServiceAsyncClient, "grpc_asyncio"), + ], ) def test_identity_aware_proxy_admin_service_client_from_service_account_info( - client_class, + client_class, transport_name ): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -113,11 +112,11 @@ def test_identity_aware_proxy_admin_service_client_from_service_account_info( ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") @pytest.mark.parametrize( @@ -146,26 +145,33 @@ def test_identity_aware_proxy_admin_service_client_service_account_always_use_jw @pytest.mark.parametrize( - "client_class", - [IdentityAwareProxyAdminServiceClient, IdentityAwareProxyAdminServiceAsyncClient,], + "client_class,transport_name", + [ + (IdentityAwareProxyAdminServiceClient, "grpc"), + (IdentityAwareProxyAdminServiceAsyncClient, "grpc_asyncio"), + ], ) def test_identity_aware_proxy_admin_service_client_from_service_account_file( - client_class, + client_class, transport_name ): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") def test_identity_aware_proxy_admin_service_client_get_transport_class(): @@ -538,7 +544,9 @@ def test_identity_aware_proxy_admin_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -678,10 +686,17 @@ def test_identity_aware_proxy_admin_service_client_create_channel_credentials_fi ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -691,7 +706,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -709,7 +727,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -725,7 +744,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -736,7 +756,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -765,7 +788,7 @@ def test_set_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -779,7 +802,10 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -792,7 +818,7 @@ async def test_set_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -806,7 +832,10 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): @@ -821,15 +850,23 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -839,7 +876,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -857,7 +897,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -873,7 +914,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -884,7 +926,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -913,7 +958,7 @@ def test_get_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -927,7 +972,10 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -940,7 +988,7 @@ async def test_get_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -954,7 +1002,10 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): @@ -975,11 +1026,16 @@ def test_get_iam_policy_from_dict_foreign(): @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1010,7 +1066,8 @@ def test_test_iam_permissions_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", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1029,7 +1086,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1072,7 +1130,7 @@ def test_test_iam_permissions_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1088,7 +1146,10 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1101,7 +1162,7 @@ async def test_test_iam_permissions_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1119,7 +1180,10 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): @@ -1141,10 +1205,17 @@ def test_test_iam_permissions_from_dict_foreign(): call.assert_called() -@pytest.mark.parametrize("request_type", [service.GetIapSettingsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetIapSettingsRequest, + dict, + ], +) def test_get_iap_settings(request_type, transport: str = "grpc"): client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1154,7 +1225,9 @@ def test_get_iap_settings(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iap_settings), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = service.IapSettings(name="name_value",) + call.return_value = service.IapSettings( + name="name_value", + ) response = client.get_iap_settings(request) # Establish that the underlying gRPC stub method was called. @@ -1171,7 +1244,8 @@ def test_get_iap_settings_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", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1187,7 +1261,8 @@ async def test_get_iap_settings_async( transport: str = "grpc_asyncio", request_type=service.GetIapSettingsRequest ): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1198,7 +1273,9 @@ async def test_get_iap_settings_async( with mock.patch.object(type(client.transport.get_iap_settings), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.IapSettings(name="name_value",) + service.IapSettings( + name="name_value", + ) ) response = await client.get_iap_settings(request) @@ -1226,7 +1303,7 @@ def test_get_iap_settings_field_headers(): # a field header. Set these to a non-empty value. request = service.GetIapSettingsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iap_settings), "__call__") as call: @@ -1240,7 +1317,10 @@ def test_get_iap_settings_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1253,7 +1333,7 @@ async def test_get_iap_settings_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetIapSettingsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iap_settings), "__call__") as call: @@ -1267,13 +1347,23 @@ async def test_get_iap_settings_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [service.UpdateIapSettingsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateIapSettingsRequest, + dict, + ], +) def test_update_iap_settings(request_type, transport: str = "grpc"): client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1285,7 +1375,9 @@ def test_update_iap_settings(request_type, transport: str = "grpc"): type(client.transport.update_iap_settings), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.IapSettings(name="name_value",) + call.return_value = service.IapSettings( + name="name_value", + ) response = client.update_iap_settings(request) # Establish that the underlying gRPC stub method was called. @@ -1302,7 +1394,8 @@ def test_update_iap_settings_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", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,7 +1413,8 @@ async def test_update_iap_settings_async( transport: str = "grpc_asyncio", request_type=service.UpdateIapSettingsRequest ): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1333,7 +1427,9 @@ async def test_update_iap_settings_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.IapSettings(name="name_value",) + service.IapSettings( + name="name_value", + ) ) response = await client.update_iap_settings(request) @@ -1361,7 +1457,7 @@ def test_update_iap_settings_field_headers(): # a field header. Set these to a non-empty value. request = service.UpdateIapSettingsRequest() - request.iap_settings.name = "iap_settings.name/value" + request.iap_settings.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1379,7 +1475,7 @@ def test_update_iap_settings_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "iap_settings.name=iap_settings.name/value", + "iap_settings.name=name_value", ) in kw["metadata"] @@ -1393,7 +1489,7 @@ async def test_update_iap_settings_field_headers_async(): # a field header. Set these to a non-empty value. request = service.UpdateIapSettingsRequest() - request.iap_settings.name = "iap_settings.name/value" + request.iap_settings.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1411,146 +1507,1646 @@ async def test_update_iap_settings_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "iap_settings.name=iap_settings.name/value", + "iap_settings.name=name_value", ) in kw["metadata"] -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( +@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, ) - with pytest.raises(ValueError): - client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = IdentityAwareProxyAdminServiceClient( - client_options={"credentials_file": "credentials.json"}, - 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() - # It is an error to provide an api_key and a transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = IdentityAwareProxyAdminServiceClient( - client_options=options, transport=transport, + # 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) - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = IdentityAwareProxyAdminServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) + # 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() - # It is an error to provide scopes and a transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = IdentityAwareProxyAdminServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, - ) + # 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_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( +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", ) - client = IdentityAwareProxyAdminServiceClient(transport=transport) - assert client.transport is transport + # 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() -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - transport = transports.IdentityAwareProxyAdminServiceGrpcAsyncIOTransport( +@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, ) - channel = transport.grpc_channel - assert channel + # 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() -@pytest.mark.parametrize( - "transport_class", - [ - transports.IdentityAwareProxyAdminServiceGrpcTransport, - transports.IdentityAwareProxyAdminServiceGrpcAsyncIOTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - + # 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) -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, transports.IdentityAwareProxyAdminServiceGrpcTransport, - ) + # 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" -def test_identity_aware_proxy_admin_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.IdentityAwareProxyAdminServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) +@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_identity_aware_proxy_admin_service_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.transports.IdentityAwareProxyAdminServiceTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.IdentityAwareProxyAdminServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "set_iam_policy", - "get_iam_policy", - "test_iam_permissions", - "get_iap_settings", - "update_iap_settings", +def test_list_tunnel_dest_groups_field_headers(): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - with pytest.raises(NotImplementedError): - transport.close() + # 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" -def test_identity_aware_proxy_admin_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file + # 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( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = IdentityAwareProxyAdminServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IdentityAwareProxyAdminServiceClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IdentityAwareProxyAdminServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = IdentityAwareProxyAdminServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = IdentityAwareProxyAdminServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.IdentityAwareProxyAdminServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.IdentityAwareProxyAdminServiceGrpcTransport, + transports.IdentityAwareProxyAdminServiceGrpcAsyncIOTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = IdentityAwareProxyAdminServiceClient.get_transport_class( + transport_name + )( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = IdentityAwareProxyAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.IdentityAwareProxyAdminServiceGrpcTransport, + ) + + +def test_identity_aware_proxy_admin_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.IdentityAwareProxyAdminServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_identity_aware_proxy_admin_service_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.cloud.iap_v1.services.identity_aware_proxy_admin_service.transports.IdentityAwareProxyAdminServiceTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.IdentityAwareProxyAdminServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "set_iam_policy", + "get_iam_policy", + "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): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_identity_aware_proxy_admin_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file with mock.patch.object( google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( @@ -1559,7 +3155,8 @@ def test_identity_aware_proxy_admin_service_base_transport_with_credentials_file Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IdentityAwareProxyAdminServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1699,22 +3296,38 @@ def test_identity_aware_proxy_admin_service_grpc_transport_client_cert_source_fo ) -def test_identity_aware_proxy_admin_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_identity_aware_proxy_admin_service_host_no_port(transport_name): client = IdentityAwareProxyAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="iap.googleapis.com"), + transport=transport_name, ) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") -def test_identity_aware_proxy_admin_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_identity_aware_proxy_admin_service_host_with_port(transport_name): client = IdentityAwareProxyAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="iap.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "iap.googleapis.com:8000" + assert client.transport._host == ("iap.googleapis.com:8000") def test_identity_aware_proxy_admin_service_grpc_transport_channel(): @@ -1722,7 +3335,8 @@ def test_identity_aware_proxy_admin_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.IdentityAwareProxyAdminServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1734,7 +3348,8 @@ def test_identity_aware_proxy_admin_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.IdentityAwareProxyAdminServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1843,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, ) @@ -1856,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) @@ -1868,15 +3536,17 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + folder = "squid" + expected = "folders/{folder}".format( + folder=folder, + ) actual = IdentityAwareProxyAdminServiceClient.common_folder_path(folder) assert expected == actual def test_parse_common_folder_path(): expected = { - "folder": "octopus", + "folder": "clam", } path = IdentityAwareProxyAdminServiceClient.common_folder_path(**expected) @@ -1886,15 +3556,17 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + organization = "whelk" + expected = "organizations/{organization}".format( + organization=organization, + ) actual = IdentityAwareProxyAdminServiceClient.common_organization_path(organization) assert expected == actual def test_parse_common_organization_path(): expected = { - "organization": "nudibranch", + "organization": "octopus", } path = IdentityAwareProxyAdminServiceClient.common_organization_path(**expected) @@ -1904,15 +3576,17 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + project = "oyster" + expected = "projects/{project}".format( + project=project, + ) actual = IdentityAwareProxyAdminServiceClient.common_project_path(project) assert expected == actual def test_parse_common_project_path(): expected = { - "project": "mussel", + "project": "nudibranch", } path = IdentityAwareProxyAdminServiceClient.common_project_path(**expected) @@ -1922,10 +3596,11 @@ 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, + project=project, + location=location, ) actual = IdentityAwareProxyAdminServiceClient.common_location_path( project, location @@ -1935,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) @@ -1952,7 +3627,8 @@ def test_client_with_default_client_info(): transports.IdentityAwareProxyAdminServiceTransport, "_prep_wrapped_messages" ) as prep: client = IdentityAwareProxyAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1961,7 +3637,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = IdentityAwareProxyAdminServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1969,7 +3646,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = IdentityAwareProxyAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/iap_v1/test_identity_aware_proxy_o_auth_service.py b/tests/unit/gapic/iap_v1/test_identity_aware_proxy_o_auth_service.py index a01f37d..3867af4 100644 --- a/tests/unit/gapic/iap_v1/test_identity_aware_proxy_o_auth_service.py +++ b/tests/unit/gapic/iap_v1/test_identity_aware_proxy_o_auth_service.py @@ -13,35 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.oauth2 import service_account +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import ( IdentityAwareProxyOAuthServiceAsyncClient, -) -from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import ( IdentityAwareProxyOAuthServiceClient, + pagers, + transports, ) -from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import pagers -from google.cloud.iap_v1.services.identity_aware_proxy_o_auth_service import transports from google.cloud.iap_v1.types import service -from google.oauth2 import service_account -import google.auth def client_cert_source_callback(): @@ -96,11 +90,14 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", - [IdentityAwareProxyOAuthServiceClient, IdentityAwareProxyOAuthServiceAsyncClient,], + "client_class,transport_name", + [ + (IdentityAwareProxyOAuthServiceClient, "grpc"), + (IdentityAwareProxyOAuthServiceAsyncClient, "grpc_asyncio"), + ], ) def test_identity_aware_proxy_o_auth_service_client_from_service_account_info( - client_class, + client_class, transport_name ): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -108,11 +105,11 @@ def test_identity_aware_proxy_o_auth_service_client_from_service_account_info( ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") @pytest.mark.parametrize( @@ -141,26 +138,33 @@ def test_identity_aware_proxy_o_auth_service_client_service_account_always_use_j @pytest.mark.parametrize( - "client_class", - [IdentityAwareProxyOAuthServiceClient, IdentityAwareProxyOAuthServiceAsyncClient,], + "client_class,transport_name", + [ + (IdentityAwareProxyOAuthServiceClient, "grpc"), + (IdentityAwareProxyOAuthServiceAsyncClient, "grpc_asyncio"), + ], ) def test_identity_aware_proxy_o_auth_service_client_from_service_account_file( - client_class, + client_class, transport_name ): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") def test_identity_aware_proxy_o_auth_service_client_get_transport_class(): @@ -533,7 +537,9 @@ def test_identity_aware_proxy_o_auth_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -673,10 +679,17 @@ def test_identity_aware_proxy_o_auth_service_client_create_channel_credentials_f ) -@pytest.mark.parametrize("request_type", [service.ListBrandsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.ListBrandsRequest, + dict, + ], +) def test_list_brands(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -702,7 +715,8 @@ def test_list_brands_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -718,7 +732,8 @@ async def test_list_brands_async( transport: str = "grpc_asyncio", request_type=service.ListBrandsRequest ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -756,7 +771,7 @@ def test_list_brands_field_headers(): # a field header. Set these to a non-empty value. request = service.ListBrandsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_brands), "__call__") as call: @@ -770,7 +785,10 @@ def test_list_brands_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -783,7 +801,7 @@ async def test_list_brands_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ListBrandsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_brands), "__call__") as call: @@ -799,13 +817,23 @@ async def test_list_brands_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [service.CreateBrandRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.CreateBrandRequest, + dict, + ], +) def test_create_brand(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -840,7 +868,8 @@ def test_create_brand_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -856,7 +885,8 @@ async def test_create_brand_async( transport: str = "grpc_asyncio", request_type=service.CreateBrandRequest ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -903,7 +933,7 @@ def test_create_brand_field_headers(): # a field header. Set these to a non-empty value. request = service.CreateBrandRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_brand), "__call__") as call: @@ -917,7 +947,10 @@ def test_create_brand_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -930,7 +963,7 @@ async def test_create_brand_field_headers_async(): # a field header. Set these to a non-empty value. request = service.CreateBrandRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_brand), "__call__") as call: @@ -944,13 +977,23 @@ async def test_create_brand_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [service.GetBrandRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetBrandRequest, + dict, + ], +) def test_get_brand(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -985,7 +1028,8 @@ def test_get_brand_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1001,7 +1045,8 @@ async def test_get_brand_async( transport: str = "grpc_asyncio", request_type=service.GetBrandRequest ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1048,7 +1093,7 @@ def test_get_brand_field_headers(): # a field header. Set these to a non-empty value. request = service.GetBrandRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_brand), "__call__") as call: @@ -1062,7 +1107,10 @@ def test_get_brand_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1075,7 +1123,7 @@ async def test_get_brand_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetBrandRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_brand), "__call__") as call: @@ -1089,15 +1137,23 @@ async def test_get_brand_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [service.CreateIdentityAwareProxyClientRequest, dict,] + "request_type", + [ + service.CreateIdentityAwareProxyClientRequest, + dict, + ], ) def test_create_identity_aware_proxy_client(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1110,7 +1166,9 @@ def test_create_identity_aware_proxy_client(request_type, transport: str = "grpc ) as call: # Designate an appropriate return value for the call. call.return_value = service.IdentityAwareProxyClient( - name="name_value", secret="secret_value", display_name="display_name_value", + name="name_value", + secret="secret_value", + display_name="display_name_value", ) response = client.create_identity_aware_proxy_client(request) @@ -1130,7 +1188,8 @@ def test_create_identity_aware_proxy_client_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1149,7 +1208,8 @@ async def test_create_identity_aware_proxy_client_async( request_type=service.CreateIdentityAwareProxyClientRequest, ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1196,7 +1256,7 @@ def test_create_identity_aware_proxy_client_field_headers(): # a field header. Set these to a non-empty value. request = service.CreateIdentityAwareProxyClientRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1212,7 +1272,10 @@ def test_create_identity_aware_proxy_client_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1225,7 +1288,7 @@ async def test_create_identity_aware_proxy_client_field_headers_async(): # a field header. Set these to a non-empty value. request = service.CreateIdentityAwareProxyClientRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1243,15 +1306,23 @@ async def test_create_identity_aware_proxy_client_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [service.ListIdentityAwareProxyClientsRequest, dict,] + "request_type", + [ + service.ListIdentityAwareProxyClientsRequest, + dict, + ], ) def test_list_identity_aware_proxy_clients(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1282,7 +1353,8 @@ def test_list_identity_aware_proxy_clients_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1301,7 +1373,8 @@ async def test_list_identity_aware_proxy_clients_async( request_type=service.ListIdentityAwareProxyClientsRequest, ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1344,7 +1417,7 @@ def test_list_identity_aware_proxy_clients_field_headers(): # a field header. Set these to a non-empty value. request = service.ListIdentityAwareProxyClientsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1360,7 +1433,10 @@ def test_list_identity_aware_proxy_clients_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1373,7 +1449,7 @@ async def test_list_identity_aware_proxy_clients_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ListIdentityAwareProxyClientsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1391,12 +1467,16 @@ async def test_list_identity_aware_proxy_clients_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_identity_aware_proxy_clients_pager(transport_name: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1414,10 +1494,13 @@ def test_list_identity_aware_proxy_clients_pager(transport_name: str = "grpc"): next_page_token="abc", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[], next_page_token="def", + identity_aware_proxy_clients=[], + next_page_token="def", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[service.IdentityAwareProxyClient(),], + identity_aware_proxy_clients=[ + service.IdentityAwareProxyClient(), + ], next_page_token="ghi", ), service.ListIdentityAwareProxyClientsResponse( @@ -1437,14 +1520,15 @@ def test_list_identity_aware_proxy_clients_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, service.IdentityAwareProxyClient) for i in results) def test_list_identity_aware_proxy_clients_pages(transport_name: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1462,10 +1546,13 @@ def test_list_identity_aware_proxy_clients_pages(transport_name: str = "grpc"): next_page_token="abc", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[], next_page_token="def", + identity_aware_proxy_clients=[], + next_page_token="def", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[service.IdentityAwareProxyClient(),], + identity_aware_proxy_clients=[ + service.IdentityAwareProxyClient(), + ], next_page_token="ghi", ), service.ListIdentityAwareProxyClientsResponse( @@ -1504,10 +1591,13 @@ async def test_list_identity_aware_proxy_clients_async_pager(): next_page_token="abc", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[], next_page_token="def", + identity_aware_proxy_clients=[], + next_page_token="def", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[service.IdentityAwareProxyClient(),], + identity_aware_proxy_clients=[ + service.IdentityAwareProxyClient(), + ], next_page_token="ghi", ), service.ListIdentityAwareProxyClientsResponse( @@ -1518,10 +1608,12 @@ async def test_list_identity_aware_proxy_clients_async_pager(): ), RuntimeError, ) - async_pager = await client.list_identity_aware_proxy_clients(request={},) + async_pager = await client.list_identity_aware_proxy_clients( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1551,10 +1643,13 @@ async def test_list_identity_aware_proxy_clients_async_pages(): next_page_token="abc", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[], next_page_token="def", + identity_aware_proxy_clients=[], + next_page_token="def", ), service.ListIdentityAwareProxyClientsResponse( - identity_aware_proxy_clients=[service.IdentityAwareProxyClient(),], + identity_aware_proxy_clients=[ + service.IdentityAwareProxyClient(), + ], next_page_token="ghi", ), service.ListIdentityAwareProxyClientsResponse( @@ -1568,18 +1663,23 @@ async def test_list_identity_aware_proxy_clients_async_pages(): pages = [] async for page_ in ( await client.list_identity_aware_proxy_clients(request={}) - ).pages: + ).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.GetIdentityAwareProxyClientRequest, dict,] + "request_type", + [ + service.GetIdentityAwareProxyClientRequest, + dict, + ], ) def test_get_identity_aware_proxy_client(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1592,7 +1692,9 @@ def test_get_identity_aware_proxy_client(request_type, transport: str = "grpc"): ) as call: # Designate an appropriate return value for the call. call.return_value = service.IdentityAwareProxyClient( - name="name_value", secret="secret_value", display_name="display_name_value", + name="name_value", + secret="secret_value", + display_name="display_name_value", ) response = client.get_identity_aware_proxy_client(request) @@ -1612,7 +1714,8 @@ def test_get_identity_aware_proxy_client_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1631,7 +1734,8 @@ async def test_get_identity_aware_proxy_client_async( request_type=service.GetIdentityAwareProxyClientRequest, ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1678,7 +1782,7 @@ def test_get_identity_aware_proxy_client_field_headers(): # a field header. Set these to a non-empty value. request = service.GetIdentityAwareProxyClientRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1694,7 +1798,10 @@ def test_get_identity_aware_proxy_client_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1707,7 +1814,7 @@ async def test_get_identity_aware_proxy_client_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetIdentityAwareProxyClientRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1725,17 +1832,25 @@ async def test_get_identity_aware_proxy_client_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [service.ResetIdentityAwareProxyClientSecretRequest, dict,] + "request_type", + [ + service.ResetIdentityAwareProxyClientSecretRequest, + dict, + ], ) def test_reset_identity_aware_proxy_client_secret( request_type, transport: str = "grpc" ): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1748,7 +1863,9 @@ def test_reset_identity_aware_proxy_client_secret( ) as call: # Designate an appropriate return value for the call. call.return_value = service.IdentityAwareProxyClient( - name="name_value", secret="secret_value", display_name="display_name_value", + name="name_value", + secret="secret_value", + display_name="display_name_value", ) response = client.reset_identity_aware_proxy_client_secret(request) @@ -1768,7 +1885,8 @@ def test_reset_identity_aware_proxy_client_secret_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1787,7 +1905,8 @@ async def test_reset_identity_aware_proxy_client_secret_async( request_type=service.ResetIdentityAwareProxyClientSecretRequest, ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1834,7 +1953,7 @@ def test_reset_identity_aware_proxy_client_secret_field_headers(): # a field header. Set these to a non-empty value. request = service.ResetIdentityAwareProxyClientSecretRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1850,7 +1969,10 @@ def test_reset_identity_aware_proxy_client_secret_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1863,7 +1985,7 @@ async def test_reset_identity_aware_proxy_client_secret_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ResetIdentityAwareProxyClientSecretRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1881,15 +2003,23 @@ async def test_reset_identity_aware_proxy_client_secret_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [service.DeleteIdentityAwareProxyClientRequest, dict,] + "request_type", + [ + service.DeleteIdentityAwareProxyClientRequest, + dict, + ], ) def test_delete_identity_aware_proxy_client(request_type, transport: str = "grpc"): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1917,7 +2047,8 @@ def test_delete_identity_aware_proxy_client_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 = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1936,7 +2067,8 @@ async def test_delete_identity_aware_proxy_client_async( request_type=service.DeleteIdentityAwareProxyClientRequest, ): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1974,7 +2106,7 @@ def test_delete_identity_aware_proxy_client_field_headers(): # a field header. Set these to a non-empty value. request = service.DeleteIdentityAwareProxyClientRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1990,7 +2122,10 @@ def test_delete_identity_aware_proxy_client_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2003,7 +2138,7 @@ async def test_delete_identity_aware_proxy_client_field_headers_async(): # a field header. Set these to a non-empty value. request = service.DeleteIdentityAwareProxyClientRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2019,7 +2154,10 @@ async def test_delete_identity_aware_proxy_client_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -2029,7 +2167,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2050,7 +2189,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = IdentityAwareProxyOAuthServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2067,7 +2207,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = IdentityAwareProxyOAuthServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2110,13 +2251,29 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = IdentityAwareProxyOAuthServiceClient.get_transport_class( + transport_name + )( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = IdentityAwareProxyOAuthServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.IdentityAwareProxyOAuthServiceGrpcTransport, + client.transport, + transports.IdentityAwareProxyOAuthServiceGrpcTransport, ) @@ -2158,6 +2315,14 @@ def test_identity_aware_proxy_o_auth_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_identity_aware_proxy_o_auth_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2169,7 +2334,8 @@ def test_identity_aware_proxy_o_auth_service_base_transport_with_credentials_fil Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IdentityAwareProxyOAuthServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2309,22 +2475,38 @@ def test_identity_aware_proxy_o_auth_service_grpc_transport_client_cert_source_f ) -def test_identity_aware_proxy_o_auth_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_identity_aware_proxy_o_auth_service_host_no_port(transport_name): client = IdentityAwareProxyOAuthServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="iap.googleapis.com"), + transport=transport_name, ) - assert client.transport._host == "iap.googleapis.com:443" + assert client.transport._host == ("iap.googleapis.com:443") -def test_identity_aware_proxy_o_auth_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_identity_aware_proxy_o_auth_service_host_with_port(transport_name): client = IdentityAwareProxyOAuthServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="iap.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "iap.googleapis.com:8000" + assert client.transport._host == ("iap.googleapis.com:8000") def test_identity_aware_proxy_o_auth_service_grpc_transport_channel(): @@ -2332,7 +2514,8 @@ def test_identity_aware_proxy_o_auth_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.IdentityAwareProxyOAuthServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2344,7 +2527,8 @@ def test_identity_aware_proxy_o_auth_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.IdentityAwareProxyOAuthServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2479,7 +2663,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = IdentityAwareProxyOAuthServiceClient.common_folder_path(folder) assert expected == actual @@ -2497,7 +2683,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = IdentityAwareProxyOAuthServiceClient.common_organization_path(organization) assert expected == actual @@ -2515,7 +2703,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = IdentityAwareProxyOAuthServiceClient.common_project_path(project) assert expected == actual @@ -2535,7 +2725,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = IdentityAwareProxyOAuthServiceClient.common_location_path( project, location @@ -2562,7 +2753,8 @@ def test_client_with_default_client_info(): transports.IdentityAwareProxyOAuthServiceTransport, "_prep_wrapped_messages" ) as prep: client = IdentityAwareProxyOAuthServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2571,7 +2763,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = IdentityAwareProxyOAuthServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2579,7 +2772,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = IdentityAwareProxyOAuthServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"