From 1fb9db54adc391b30e10f475094b3b22ad5d4fdb Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 29 Jun 2021 02:25:15 +0000 Subject: [PATCH 1/8] fix: add dependencies for google/cloud/gkehub Committer: @parthea PiperOrigin-RevId: 381971413 Source-Link: https://github.com/googleapis/googleapis/commit/b6b4b89cae9b4734b7810c65a4fa69b5e9083cdc Source-Link: https://github.com/googleapis/googleapis-gen/commit/7519297e25de9b9fb3a6d22dc59f55d5e3382472 --- owl-bot-staging/v1/.coveragerc | 17 + owl-bot-staging/v1/MANIFEST.in | 2 + owl-bot-staging/v1/README.rst | 49 + owl-bot-staging/v1/docs/conf.py | 376 ++ .../v1/docs/configmanagement_v1/services.rst | 4 + .../v1/docs/configmanagement_v1/types.rst | 7 + owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst | 10 + .../v1/docs/gkehub_v1/services.rst | 6 + owl-bot-staging/v1/docs/gkehub_v1/types.rst | 7 + owl-bot-staging/v1/docs/index.rst | 7 + .../docs/multiclusteringress_v1/services.rst | 4 + .../v1/docs/multiclusteringress_v1/types.rst | 7 + .../v1/google/cloud/gkehub/__init__.py | 83 + .../cloud/gkehub/configmanagement/__init__.py | 63 + .../cloud/gkehub/configmanagement/py.typed | 2 + .../gkehub/configmanagement_v1/__init__.py | 64 + .../configmanagement_v1/gapic_metadata.json | 7 + .../cloud/gkehub/configmanagement_v1/py.typed | 2 + .../configmanagement_v1/services/__init__.py | 15 + .../configmanagement_v1/types/__init__.py | 64 + .../types/configmanagement.py | 773 ++++ .../gkehub/multiclusteringress/__init__.py | 21 + .../cloud/gkehub/multiclusteringress/py.typed | 2 + .../gkehub/multiclusteringress_v1/__init__.py | 22 + .../gapic_metadata.json | 7 + .../gkehub/multiclusteringress_v1/py.typed | 2 + .../services/__init__.py | 15 + .../multiclusteringress_v1/types/__init__.py | 22 + .../types/multiclusteringress.py | 44 + .../v1/google/cloud/gkehub/py.typed | 2 + .../v1/google/cloud/gkehub_v1/__init__.py | 84 + .../cloud/gkehub_v1/gapic_metadata.json | 133 + .../v1/google/cloud/gkehub_v1/py.typed | 2 + .../cloud/gkehub_v1/services/__init__.py | 15 + .../gkehub_v1/services/gke_hub/__init__.py | 22 + .../services/gke_hub/async_client.py | 1211 +++++ .../gkehub_v1/services/gke_hub/client.py | 1408 ++++++ .../gkehub_v1/services/gke_hub/pagers.py | 264 ++ .../services/gke_hub/transports/__init__.py | 33 + .../services/gke_hub/transports/base.py | 317 ++ .../services/gke_hub/transports/grpc.py | 555 +++ .../gke_hub/transports/grpc_asyncio.py | 559 +++ .../google/cloud/gkehub_v1/types/__init__.py | 84 + .../google/cloud/gkehub_v1/types/feature.py | 294 ++ .../cloud/gkehub_v1/types/membership.py | 349 ++ .../google/cloud/gkehub_v1/types/service.py | 758 ++++ owl-bot-staging/v1/mypy.ini | 3 + owl-bot-staging/v1/noxfile.py | 132 + .../fixup_configmanagement_v1_keywords.py | 175 + .../v1/scripts/fixup_gkehub_v1_keywords.py | 186 + .../fixup_multiclusteringress_v1_keywords.py | 175 + owl-bot-staging/v1/setup.py | 53 + owl-bot-staging/v1/tests/__init__.py | 16 + owl-bot-staging/v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../gapic/configmanagement_v1/__init__.py | 16 + .../v1/tests/unit/gapic/gkehub_v1/__init__.py | 16 + .../unit/gapic/gkehub_v1/test_gke_hub.py | 3883 +++++++++++++++++ .../gapic/multiclusteringress_v1/__init__.py | 16 + owl-bot-staging/v1alpha/.coveragerc | 17 + owl-bot-staging/v1alpha/MANIFEST.in | 2 + owl-bot-staging/v1alpha/README.rst | 49 + .../cloudauditlogging_v1alpha/services.rst | 4 + .../docs/cloudauditlogging_v1alpha/types.rst | 7 + owl-bot-staging/v1alpha/docs/conf.py | 376 ++ .../configmanagement_v1alpha/services.rst | 4 + .../docs/configmanagement_v1alpha/types.rst | 7 + .../v1alpha/docs/gkehub_v1alpha/gke_hub.rst | 10 + .../v1alpha/docs/gkehub_v1alpha/services.rst | 6 + .../v1alpha/docs/gkehub_v1alpha/types.rst | 7 + owl-bot-staging/v1alpha/docs/index.rst | 7 + .../docs/metering_v1alpha/services.rst | 4 + .../v1alpha/docs/metering_v1alpha/types.rst | 7 + .../multiclusteringress_v1alpha/services.rst | 4 + .../multiclusteringress_v1alpha/types.rst | 7 + .../docs/servicemesh_v1alpha/services.rst | 4 + .../docs/servicemesh_v1alpha/types.rst | 7 + .../v1alpha/google/cloud/gkehub/__init__.py | 51 + .../gkehub/cloudauditlogging/__init__.py | 21 + .../cloud/gkehub/cloudauditlogging/py.typed | 2 + .../cloudauditlogging_v1alpha/__init__.py | 22 + .../gapic_metadata.json | 7 + .../gkehub/cloudauditlogging_v1alpha/py.typed | 2 + .../services/__init__.py | 15 + .../types/__init__.py | 22 + .../types/cloudauditlogging.py | 47 + .../cloud/gkehub/configmanagement/__init__.py | 69 + .../cloud/gkehub/configmanagement/py.typed | 2 + .../configmanagement_v1alpha/__init__.py | 70 + .../gapic_metadata.json | 7 + .../gkehub/configmanagement_v1alpha/py.typed | 2 + .../services/__init__.py | 15 + .../types/__init__.py | 70 + .../types/configmanagement.py | 852 ++++ .../google/cloud/gkehub/metering/__init__.py | 21 + .../google/cloud/gkehub/metering/py.typed | 2 + .../cloud/gkehub/metering_v1alpha/__init__.py | 22 + .../metering_v1alpha/gapic_metadata.json | 7 + .../cloud/gkehub/metering_v1alpha/py.typed | 2 + .../metering_v1alpha/services/__init__.py | 15 + .../gkehub/metering_v1alpha/types/__init__.py | 22 + .../gkehub/metering_v1alpha/types/metering.py | 52 + .../gkehub/multiclusteringress/__init__.py | 23 + .../cloud/gkehub/multiclusteringress/py.typed | 2 + .../multiclusteringress_v1alpha/__init__.py | 24 + .../gapic_metadata.json | 7 + .../multiclusteringress_v1alpha/py.typed | 2 + .../services/__init__.py | 15 + .../types/__init__.py | 24 + .../types/multiclusteringress.py | 61 + .../v1alpha/google/cloud/gkehub/py.typed | 2 + .../cloud/gkehub/servicemesh/__init__.py | 27 + .../google/cloud/gkehub/servicemesh/py.typed | 2 + .../gkehub/servicemesh_v1alpha/__init__.py | 28 + .../servicemesh_v1alpha/gapic_metadata.json | 7 + .../cloud/gkehub/servicemesh_v1alpha/py.typed | 2 + .../servicemesh_v1alpha/services/__init__.py | 15 + .../servicemesh_v1alpha/types/__init__.py | 28 + .../servicemesh_v1alpha/types/servicemesh.py | 179 + .../google/cloud/gkehub_v1alpha/__init__.py | 52 + .../cloud/gkehub_v1alpha/gapic_metadata.json | 73 + .../google/cloud/gkehub_v1alpha/py.typed | 2 + .../cloud/gkehub_v1alpha/services/__init__.py | 15 + .../services/gke_hub/__init__.py | 22 + .../services/gke_hub/async_client.py | 657 +++ .../gkehub_v1alpha/services/gke_hub/client.py | 844 ++++ .../gkehub_v1alpha/services/gke_hub/pagers.py | 141 + .../services/gke_hub/transports/__init__.py | 33 + .../services/gke_hub/transports/base.py | 232 + .../services/gke_hub/transports/grpc.py | 386 ++ .../gke_hub/transports/grpc_asyncio.py | 390 ++ .../cloud/gkehub_v1alpha/types/__init__.py | 50 + .../cloud/gkehub_v1alpha/types/feature.py | 329 ++ .../cloud/gkehub_v1alpha/types/service.py | 351 ++ owl-bot-staging/v1alpha/mypy.ini | 3 + owl-bot-staging/v1alpha/noxfile.py | 132 + ...ixup_cloudauditlogging_v1alpha_keywords.py | 175 + ...fixup_configmanagement_v1alpha_keywords.py | 175 + .../scripts/fixup_gkehub_v1alpha_keywords.py | 180 + .../fixup_metering_v1alpha_keywords.py | 175 + ...up_multiclusteringress_v1alpha_keywords.py | 175 + .../fixup_servicemesh_v1alpha_keywords.py | 175 + owl-bot-staging/v1alpha/setup.py | 53 + owl-bot-staging/v1alpha/tests/__init__.py | 16 + .../v1alpha/tests/unit/__init__.py | 16 + .../v1alpha/tests/unit/gapic/__init__.py | 16 + .../cloudauditlogging_v1alpha/__init__.py | 16 + .../configmanagement_v1alpha/__init__.py | 16 + .../unit/gapic/gkehub_v1alpha/__init__.py | 16 + .../unit/gapic/gkehub_v1alpha/test_gke_hub.py | 2336 ++++++++++ .../unit/gapic/metering_v1alpha/__init__.py | 16 + .../multiclusteringress_v1alpha/__init__.py | 16 + .../gapic/servicemesh_v1alpha/__init__.py | 16 + owl-bot-staging/v1alpha2/.coveragerc | 17 + owl-bot-staging/v1alpha2/MANIFEST.in | 2 + owl-bot-staging/v1alpha2/README.rst | 49 + owl-bot-staging/v1alpha2/docs/conf.py | 376 ++ .../v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst | 10 + .../docs/gkehub_v1alpha2/services.rst | 6 + .../v1alpha2/docs/gkehub_v1alpha2/types.rst | 7 + owl-bot-staging/v1alpha2/docs/index.rst | 7 + .../v1alpha2/google/cloud/gkehub/__init__.py | 67 + .../v1alpha2/google/cloud/gkehub/py.typed | 2 + .../google/cloud/gkehub_v1alpha2/__init__.py | 68 + .../cloud/gkehub_v1alpha2/gapic_metadata.json | 93 + .../google/cloud/gkehub_v1alpha2/py.typed | 2 + .../gkehub_v1alpha2/services/__init__.py | 15 + .../services/gke_hub/__init__.py | 22 + .../services/gke_hub/async_client.py | 775 ++++ .../services/gke_hub/client.py | 964 ++++ .../services/gke_hub/pagers.py | 140 + .../services/gke_hub/transports/__init__.py | 33 + .../services/gke_hub/transports/base.py | 259 ++ .../services/gke_hub/transports/grpc.py | 436 ++ .../gke_hub/transports/grpc_asyncio.py | 440 ++ .../cloud/gkehub_v1alpha2/types/__init__.py | 64 + .../cloud/gkehub_v1alpha2/types/membership.py | 952 ++++ owl-bot-staging/v1alpha2/mypy.ini | 3 + owl-bot-staging/v1alpha2/noxfile.py | 132 + .../scripts/fixup_gkehub_v1alpha2_keywords.py | 182 + owl-bot-staging/v1alpha2/setup.py | 53 + owl-bot-staging/v1alpha2/tests/__init__.py | 16 + .../v1alpha2/tests/unit/__init__.py | 16 + .../v1alpha2/tests/unit/gapic/__init__.py | 16 + .../unit/gapic/gkehub_v1alpha2/__init__.py | 16 + .../gapic/gkehub_v1alpha2/test_gke_hub.py | 2654 +++++++++++ owl-bot-staging/v1beta/.coveragerc | 17 + owl-bot-staging/v1beta/MANIFEST.in | 2 + owl-bot-staging/v1beta/README.rst | 49 + owl-bot-staging/v1beta/docs/conf.py | 376 ++ .../docs/configmanagement_v1beta/services.rst | 4 + .../docs/configmanagement_v1beta/types.rst | 7 + .../v1beta/docs/gkehub_v1beta/gke_hub.rst | 10 + .../v1beta/docs/gkehub_v1beta/services.rst | 6 + .../v1beta/docs/gkehub_v1beta/types.rst | 7 + owl-bot-staging/v1beta/docs/index.rst | 7 + .../v1beta/docs/metering_v1beta/services.rst | 4 + .../v1beta/docs/metering_v1beta/types.rst | 7 + .../multiclusteringress_v1beta/services.rst | 4 + .../docs/multiclusteringress_v1beta/types.rst | 7 + .../v1beta/google/cloud/gkehub/__init__.py | 51 + .../cloud/gkehub/configmanagement/__init__.py | 69 + .../cloud/gkehub/configmanagement/py.typed | 2 + .../configmanagement_v1beta/__init__.py | 70 + .../gapic_metadata.json | 7 + .../gkehub/configmanagement_v1beta/py.typed | 2 + .../services/__init__.py | 15 + .../configmanagement_v1beta/types/__init__.py | 70 + .../types/configmanagement.py | 837 ++++ .../google/cloud/gkehub/metering/__init__.py | 21 + .../google/cloud/gkehub/metering/py.typed | 2 + .../cloud/gkehub/metering_v1beta/__init__.py | 22 + .../metering_v1beta/gapic_metadata.json | 7 + .../cloud/gkehub/metering_v1beta/py.typed | 2 + .../metering_v1beta/services/__init__.py | 15 + .../gkehub/metering_v1beta/types/__init__.py | 22 + .../gkehub/metering_v1beta/types/metering.py | 52 + .../gkehub/multiclusteringress/__init__.py | 23 + .../cloud/gkehub/multiclusteringress/py.typed | 2 + .../multiclusteringress_v1beta/__init__.py | 24 + .../gapic_metadata.json | 7 + .../multiclusteringress_v1beta/py.typed | 2 + .../services/__init__.py | 15 + .../types/__init__.py | 24 + .../types/multiclusteringress.py | 61 + .../v1beta/google/cloud/gkehub/py.typed | 2 + .../google/cloud/gkehub_v1beta/__init__.py | 52 + .../cloud/gkehub_v1beta/gapic_metadata.json | 73 + .../google/cloud/gkehub_v1beta/py.typed | 2 + .../cloud/gkehub_v1beta/services/__init__.py | 15 + .../services/gke_hub/__init__.py | 22 + .../services/gke_hub/async_client.py | 657 +++ .../gkehub_v1beta/services/gke_hub/client.py | 844 ++++ .../gkehub_v1beta/services/gke_hub/pagers.py | 141 + .../services/gke_hub/transports/__init__.py | 33 + .../services/gke_hub/transports/base.py | 232 + .../services/gke_hub/transports/grpc.py | 386 ++ .../gke_hub/transports/grpc_asyncio.py | 390 ++ .../cloud/gkehub_v1beta/types/__init__.py | 50 + .../cloud/gkehub_v1beta/types/feature.py | 303 ++ .../cloud/gkehub_v1beta/types/service.py | 351 ++ owl-bot-staging/v1beta/mypy.ini | 3 + owl-bot-staging/v1beta/noxfile.py | 132 + .../fixup_configmanagement_v1beta_keywords.py | 175 + .../scripts/fixup_gkehub_v1beta_keywords.py | 180 + .../scripts/fixup_metering_v1beta_keywords.py | 175 + ...xup_multiclusteringress_v1beta_keywords.py | 175 + owl-bot-staging/v1beta/setup.py | 53 + owl-bot-staging/v1beta/tests/__init__.py | 16 + owl-bot-staging/v1beta/tests/unit/__init__.py | 16 + .../v1beta/tests/unit/gapic/__init__.py | 16 + .../gapic/configmanagement_v1beta/__init__.py | 16 + .../unit/gapic/gkehub_v1beta/__init__.py | 16 + .../unit/gapic/gkehub_v1beta/test_gke_hub.py | 2333 ++++++++++ .../unit/gapic/metering_v1beta/__init__.py | 16 + .../multiclusteringress_v1beta/__init__.py | 16 + owl-bot-staging/v1beta1/.coveragerc | 17 + owl-bot-staging/v1beta1/MANIFEST.in | 2 + owl-bot-staging/v1beta1/README.rst | 49 + owl-bot-staging/v1beta1/docs/conf.py | 376 ++ .../gke_hub_membership_service.rst | 10 + .../v1beta1/docs/gkehub_v1beta1/services.rst | 6 + .../v1beta1/docs/gkehub_v1beta1/types.rst | 7 + owl-bot-staging/v1beta1/docs/index.rst | 7 + .../v1beta1/google/cloud/gkehub/__init__.py | 73 + .../v1beta1/google/cloud/gkehub/py.typed | 2 + .../google/cloud/gkehub_v1beta1/__init__.py | 74 + .../cloud/gkehub_v1beta1/gapic_metadata.json | 103 + .../google/cloud/gkehub_v1beta1/py.typed | 2 + .../cloud/gkehub_v1beta1/services/__init__.py | 15 + .../gke_hub_membership_service/__init__.py | 22 + .../async_client.py | 842 ++++ .../gke_hub_membership_service/client.py | 1032 +++++ .../gke_hub_membership_service/pagers.py | 140 + .../transports/__init__.py | 33 + .../transports/base.py | 273 ++ .../transports/grpc.py | 468 ++ .../transports/grpc_asyncio.py | 472 ++ .../cloud/gkehub_v1beta1/types/__init__.py | 70 + .../cloud/gkehub_v1beta1/types/membership.py | 1075 +++++ owl-bot-staging/v1beta1/mypy.ini | 3 + owl-bot-staging/v1beta1/noxfile.py | 132 + .../scripts/fixup_gkehub_v1beta1_keywords.py | 183 + owl-bot-staging/v1beta1/setup.py | 53 + owl-bot-staging/v1beta1/tests/__init__.py | 16 + .../v1beta1/tests/unit/__init__.py | 16 + .../v1beta1/tests/unit/gapic/__init__.py | 16 + .../unit/gapic/gkehub_v1beta1/__init__.py | 16 + .../test_gke_hub_membership_service.py | 2803 ++++++++++++ 289 files changed, 47317 insertions(+) create mode 100644 owl-bot-staging/v1/.coveragerc create mode 100644 owl-bot-staging/v1/MANIFEST.in create mode 100644 owl-bot-staging/v1/README.rst create mode 100644 owl-bot-staging/v1/docs/conf.py create mode 100644 owl-bot-staging/v1/docs/configmanagement_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/configmanagement_v1/types.rst create mode 100644 owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst create mode 100644 owl-bot-staging/v1/docs/gkehub_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/gkehub_v1/types.rst create mode 100644 owl-bot-staging/v1/docs/index.rst create mode 100644 owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py create mode 100644 owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py create mode 100644 owl-bot-staging/v1/mypy.ini create mode 100644 owl-bot-staging/v1/noxfile.py create mode 100644 owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py create mode 100644 owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py create mode 100644 owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py create mode 100644 owl-bot-staging/v1/setup.py create mode 100644 owl-bot-staging/v1/tests/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py create mode 100644 owl-bot-staging/v1alpha/.coveragerc create mode 100644 owl-bot-staging/v1alpha/MANIFEST.in create mode 100644 owl-bot-staging/v1alpha/README.rst create mode 100644 owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/conf.py create mode 100644 owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst create mode 100644 owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/index.rst create mode 100644 owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py create mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py create mode 100644 owl-bot-staging/v1alpha/mypy.ini create mode 100644 owl-bot-staging/v1alpha/noxfile.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/setup.py create mode 100644 owl-bot-staging/v1alpha/tests/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha2/.coveragerc create mode 100644 owl-bot-staging/v1alpha2/MANIFEST.in create mode 100644 owl-bot-staging/v1alpha2/README.rst create mode 100644 owl-bot-staging/v1alpha2/docs/conf.py create mode 100644 owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst create mode 100644 owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst create mode 100644 owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst create mode 100644 owl-bot-staging/v1alpha2/docs/index.rst create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py create mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py create mode 100644 owl-bot-staging/v1alpha2/mypy.ini create mode 100644 owl-bot-staging/v1alpha2/noxfile.py create mode 100644 owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py create mode 100644 owl-bot-staging/v1alpha2/setup.py create mode 100644 owl-bot-staging/v1alpha2/tests/__init__.py create mode 100644 owl-bot-staging/v1alpha2/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py create mode 100644 owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py create mode 100644 owl-bot-staging/v1beta/.coveragerc create mode 100644 owl-bot-staging/v1beta/MANIFEST.in create mode 100644 owl-bot-staging/v1beta/README.rst create mode 100644 owl-bot-staging/v1beta/docs/conf.py create mode 100644 owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst create mode 100644 owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst create mode 100644 owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst create mode 100644 owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst create mode 100644 owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst create mode 100644 owl-bot-staging/v1beta/docs/index.rst create mode 100644 owl-bot-staging/v1beta/docs/metering_v1beta/services.rst create mode 100644 owl-bot-staging/v1beta/docs/metering_v1beta/types.rst create mode 100644 owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst create mode 100644 owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py create mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py create mode 100644 owl-bot-staging/v1beta/mypy.ini create mode 100644 owl-bot-staging/v1beta/noxfile.py create mode 100644 owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py create mode 100644 owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py create mode 100644 owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py create mode 100644 owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py create mode 100644 owl-bot-staging/v1beta/setup.py create mode 100644 owl-bot-staging/v1beta/tests/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py create mode 100644 owl-bot-staging/v1beta1/.coveragerc create mode 100644 owl-bot-staging/v1beta1/MANIFEST.in create mode 100644 owl-bot-staging/v1beta1/README.rst create mode 100644 owl-bot-staging/v1beta1/docs/conf.py create mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst create mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst create mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst create mode 100644 owl-bot-staging/v1beta1/docs/index.rst create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py create mode 100644 owl-bot-staging/v1beta1/mypy.ini create mode 100644 owl-bot-staging/v1beta1/noxfile.py create mode 100644 owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py create mode 100644 owl-bot-staging/v1beta1/setup.py create mode 100644 owl-bot-staging/v1beta1/tests/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc new file mode 100644 index 0000000..3cef77b --- /dev/null +++ b/owl-bot-staging/v1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/gkehub/multiclusteringress/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in new file mode 100644 index 0000000..6199da3 --- /dev/null +++ b/owl-bot-staging/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/gkehub/multiclusteringress *.py +recursive-include google/cloud/gkehub/multiclusteringress_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst new file mode 100644 index 0000000..a4586cc --- /dev/null +++ b/owl-bot-staging/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Gkehub Multiclusteringress API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Gkehub Multiclusteringress API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py new file mode 100644 index 0000000..03b3c7b --- /dev/null +++ b/owl-bot-staging/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# +# google-cloud-gkehub-multiclusteringress documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-gkehub-multiclusteringress" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Gkehub Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-gkehub-multiclusteringress-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress.tex", + u"google-cloud-gkehub-multiclusteringress Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress", + u"Google Cloud Gkehub Multiclusteringress Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress", + u"google-cloud-gkehub-multiclusteringress Documentation", + author, + "google-cloud-gkehub-multiclusteringress", + "GAPIC library for Google Cloud Gkehub Multiclusteringress API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1/docs/configmanagement_v1/services.rst b/owl-bot-staging/v1/docs/configmanagement_v1/services.rst new file mode 100644 index 0000000..6e2fc7d --- /dev/null +++ b/owl-bot-staging/v1/docs/configmanagement_v1/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Configmanagement v1 API +======================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1/docs/configmanagement_v1/types.rst b/owl-bot-staging/v1/docs/configmanagement_v1/types.rst new file mode 100644 index 0000000..a002aa5 --- /dev/null +++ b/owl-bot-staging/v1/docs/configmanagement_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Configmanagement v1 API +===================================================== + +.. automodule:: google.cloud.gkehub.configmanagement_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst b/owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst new file mode 100644 index 0000000..198ae72 --- /dev/null +++ b/owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst @@ -0,0 +1,10 @@ +GkeHub +------------------------ + +.. automodule:: google.cloud.gkehub_v1.services.gke_hub + :members: + :inherited-members: + +.. automodule:: google.cloud.gkehub_v1.services.gke_hub.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1/docs/gkehub_v1/services.rst b/owl-bot-staging/v1/docs/gkehub_v1/services.rst new file mode 100644 index 0000000..ff81f05 --- /dev/null +++ b/owl-bot-staging/v1/docs/gkehub_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Gkehub v1 API +======================================= +.. toctree:: + :maxdepth: 2 + + gke_hub diff --git a/owl-bot-staging/v1/docs/gkehub_v1/types.rst b/owl-bot-staging/v1/docs/gkehub_v1/types.rst new file mode 100644 index 0000000..47a4a0d --- /dev/null +++ b/owl-bot-staging/v1/docs/gkehub_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub v1 API +==================================== + +.. automodule:: google.cloud.gkehub_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/docs/index.rst b/owl-bot-staging/v1/docs/index.rst new file mode 100644 index 0000000..ad67e5b --- /dev/null +++ b/owl-bot-staging/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + multiclusteringress_v1/services + multiclusteringress_v1/types diff --git a/owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst b/owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst new file mode 100644 index 0000000..9c56c78 --- /dev/null +++ b/owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Multiclusteringress v1 API +=========================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst b/owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst new file mode 100644 index 0000000..03d088d --- /dev/null +++ b/owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Multiclusteringress v1 API +======================================================== + +.. automodule:: google.cloud.gkehub.multiclusteringress_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/__init__.py new file mode 100644 index 0000000..db580ea --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/__init__.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub_v1.services.gke_hub.client import GkeHubClient +from google.cloud.gkehub_v1.services.gke_hub.async_client import GkeHubAsyncClient + +from google.cloud.gkehub_v1.types.feature import CommonFeatureSpec +from google.cloud.gkehub_v1.types.feature import CommonFeatureState +from google.cloud.gkehub_v1.types.feature import Feature +from google.cloud.gkehub_v1.types.feature import FeatureResourceState +from google.cloud.gkehub_v1.types.feature import FeatureState +from google.cloud.gkehub_v1.types.feature import MembershipFeatureSpec +from google.cloud.gkehub_v1.types.feature import MembershipFeatureState +from google.cloud.gkehub_v1.types.membership import Authority +from google.cloud.gkehub_v1.types.membership import GkeCluster +from google.cloud.gkehub_v1.types.membership import KubernetesMetadata +from google.cloud.gkehub_v1.types.membership import Membership +from google.cloud.gkehub_v1.types.membership import MembershipEndpoint +from google.cloud.gkehub_v1.types.membership import MembershipState +from google.cloud.gkehub_v1.types.service import ConnectAgentResource +from google.cloud.gkehub_v1.types.service import CreateFeatureRequest +from google.cloud.gkehub_v1.types.service import CreateMembershipRequest +from google.cloud.gkehub_v1.types.service import DeleteFeatureRequest +from google.cloud.gkehub_v1.types.service import DeleteMembershipRequest +from google.cloud.gkehub_v1.types.service import GenerateConnectManifestRequest +from google.cloud.gkehub_v1.types.service import GenerateConnectManifestResponse +from google.cloud.gkehub_v1.types.service import GetFeatureRequest +from google.cloud.gkehub_v1.types.service import GetMembershipRequest +from google.cloud.gkehub_v1.types.service import ListFeaturesRequest +from google.cloud.gkehub_v1.types.service import ListFeaturesResponse +from google.cloud.gkehub_v1.types.service import ListMembershipsRequest +from google.cloud.gkehub_v1.types.service import ListMembershipsResponse +from google.cloud.gkehub_v1.types.service import OperationMetadata +from google.cloud.gkehub_v1.types.service import TypeMeta +from google.cloud.gkehub_v1.types.service import UpdateFeatureRequest +from google.cloud.gkehub_v1.types.service import UpdateMembershipRequest + +__all__ = ('GkeHubClient', + 'GkeHubAsyncClient', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'Authority', + 'GkeCluster', + 'KubernetesMetadata', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'ConnectAgentResource', + 'CreateFeatureRequest', + 'CreateMembershipRequest', + 'DeleteFeatureRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GetFeatureRequest', + 'GetMembershipRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'OperationMetadata', + 'TypeMeta', + 'UpdateFeatureRequest', + 'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py new file mode 100644 index 0000000..a3176a9 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSync +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncDeploymentState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncVersion +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ErrorResource +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GatekeeperDeploymentState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GitConfig +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GroupVersionKind +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerConfig +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerDeploymentState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerVersion +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import InstallError +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import MembershipSpec +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import MembershipState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import OperatorState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyController +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyControllerState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyControllerVersion +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncError +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import DeploymentState + +__all__ = ('ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py new file mode 100644 index 0000000..ffa35d2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.configmanagement import ConfigSync +from .types.configmanagement import ConfigSyncDeploymentState +from .types.configmanagement import ConfigSyncState +from .types.configmanagement import ConfigSyncVersion +from .types.configmanagement import ErrorResource +from .types.configmanagement import GatekeeperDeploymentState +from .types.configmanagement import GitConfig +from .types.configmanagement import GroupVersionKind +from .types.configmanagement import HierarchyControllerConfig +from .types.configmanagement import HierarchyControllerDeploymentState +from .types.configmanagement import HierarchyControllerState +from .types.configmanagement import HierarchyControllerVersion +from .types.configmanagement import InstallError +from .types.configmanagement import MembershipSpec +from .types.configmanagement import MembershipState +from .types.configmanagement import OperatorState +from .types.configmanagement import PolicyController +from .types.configmanagement import PolicyControllerState +from .types.configmanagement import PolicyControllerVersion +from .types.configmanagement import SyncError +from .types.configmanagement import SyncState +from .types.configmanagement import DeploymentState + +__all__ = ( +'ConfigSync', +'ConfigSyncDeploymentState', +'ConfigSyncState', +'ConfigSyncVersion', +'DeploymentState', +'ErrorResource', +'GatekeeperDeploymentState', +'GitConfig', +'GroupVersionKind', +'HierarchyControllerConfig', +'HierarchyControllerDeploymentState', +'HierarchyControllerState', +'HierarchyControllerVersion', +'InstallError', +'MembershipSpec', +'MembershipState', +'OperatorState', +'PolicyController', +'PolicyControllerState', +'PolicyControllerVersion', +'SyncError', +'SyncState', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json new file mode 100644 index 0000000..4cbd386 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.configmanagement_v1", + "protoPackage": "google.cloud.gkehub.configmanagement.v1", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py new file mode 100644 index 0000000..784db8b --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .configmanagement import ( + ConfigSync, + ConfigSyncDeploymentState, + ConfigSyncState, + ConfigSyncVersion, + ErrorResource, + GatekeeperDeploymentState, + GitConfig, + GroupVersionKind, + HierarchyControllerConfig, + HierarchyControllerDeploymentState, + HierarchyControllerState, + HierarchyControllerVersion, + InstallError, + MembershipSpec, + MembershipState, + OperatorState, + PolicyController, + PolicyControllerState, + PolicyControllerVersion, + SyncError, + SyncState, + DeploymentState, +) + +__all__ = ( + 'ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py new file mode 100644 index 0000000..6cbd43e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py @@ -0,0 +1,773 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.configmanagement.v1', + manifest={ + 'DeploymentState', + 'MembershipState', + 'MembershipSpec', + 'ConfigSync', + 'GitConfig', + 'PolicyController', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerVersion', + 'HierarchyControllerState', + 'OperatorState', + 'InstallError', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ConfigSyncDeploymentState', + 'SyncState', + 'SyncError', + 'ErrorResource', + 'GroupVersionKind', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'GatekeeperDeploymentState', + }, +) + + +class DeploymentState(proto.Enum): + r"""Enum representing the state of an ACM's deployment on a + cluster + """ + DEPLOYMENT_STATE_UNSPECIFIED = 0 + NOT_INSTALLED = 1 + INSTALLED = 2 + ERROR = 3 + + +class MembershipState(proto.Message): + r"""**Anthos Config Management**: State for a single cluster. + Attributes: + cluster_name (str): + The user-defined name for the cluster used by + ClusterSelectors to group clusters together. This should + match Membership's membership_name, unless the user + installed ACM on the cluster manually prior to enabling the + ACM hub feature. Unique within a Anthos Config Management + installation. + membership_spec (google.cloud.gkehub.configmanagement_v1.types.MembershipSpec): + Membership configuration in the cluster. This + represents the actual state in the cluster, + while the MembershipSpec in the FeatureSpec + represents the intended state + operator_state (google.cloud.gkehub.configmanagement_v1.types.OperatorState): + Current install status of ACM's Operator + config_sync_state (google.cloud.gkehub.configmanagement_v1.types.ConfigSyncState): + Current sync status + policy_controller_state (google.cloud.gkehub.configmanagement_v1.types.PolicyControllerState): + PolicyController status + hierarchy_controller_state (google.cloud.gkehub.configmanagement_v1.types.HierarchyControllerState): + Hierarchy Controller status + """ + + cluster_name = proto.Field( + proto.STRING, + number=1, + ) + membership_spec = proto.Field( + proto.MESSAGE, + number=2, + message='MembershipSpec', + ) + operator_state = proto.Field( + proto.MESSAGE, + number=3, + message='OperatorState', + ) + config_sync_state = proto.Field( + proto.MESSAGE, + number=4, + message='ConfigSyncState', + ) + policy_controller_state = proto.Field( + proto.MESSAGE, + number=5, + message='PolicyControllerState', + ) + hierarchy_controller_state = proto.Field( + proto.MESSAGE, + number=7, + message='HierarchyControllerState', + ) + + +class MembershipSpec(proto.Message): + r"""**Anthos Config Management**: Configuration for a single cluster. + Intended to parallel the ConfigManagement CR. + + Attributes: + config_sync (google.cloud.gkehub.configmanagement_v1.types.ConfigSync): + Config Sync configuration for the cluster. + policy_controller (google.cloud.gkehub.configmanagement_v1.types.PolicyController): + Policy Controller configuration for the + cluster. + hierarchy_controller (google.cloud.gkehub.configmanagement_v1.types.HierarchyControllerConfig): + Hierarchy Controller configuration for the + cluster. + version (str): + Version of ACM installed. + """ + + config_sync = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSync', + ) + policy_controller = proto.Field( + proto.MESSAGE, + number=2, + message='PolicyController', + ) + hierarchy_controller = proto.Field( + proto.MESSAGE, + number=4, + message='HierarchyControllerConfig', + ) + version = proto.Field( + proto.STRING, + number=10, + ) + + +class ConfigSync(proto.Message): + r"""Configuration for Config Sync + Attributes: + git (google.cloud.gkehub.configmanagement_v1.types.GitConfig): + Git repo configuration for the cluster. + source_format (str): + Specifies whether the Config Sync Repo is + in “hierarchical” or “unstructured” mode. + """ + + git = proto.Field( + proto.MESSAGE, + number=7, + message='GitConfig', + ) + source_format = proto.Field( + proto.STRING, + number=8, + ) + + +class GitConfig(proto.Message): + r"""Git repo configuration for a single cluster. + Attributes: + sync_repo (str): + The URL of the Git repository to use as the + source of truth. + sync_branch (str): + The branch of the repository to sync from. + Default: master. + policy_dir (str): + The path within the Git repository that + represents the top level of the repo to sync. + Default: the root directory of the repository. + sync_wait_secs (int): + Period in seconds between consecutive syncs. + Default: 15. + sync_rev (str): + Git revision (tag or hash) to check out. + Default HEAD. + secret_type (str): + Type of secret configured for access to the + Git repo. + https_proxy (str): + URL for the HTTPS proxy to be used when + communicating with the Git repo. + gcp_service_account_email (str): + The GCP Service Account Email used for auth when secret_type + is gcpServiceAccount. + """ + + sync_repo = proto.Field( + proto.STRING, + number=1, + ) + sync_branch = proto.Field( + proto.STRING, + number=2, + ) + policy_dir = proto.Field( + proto.STRING, + number=3, + ) + sync_wait_secs = proto.Field( + proto.INT64, + number=4, + ) + sync_rev = proto.Field( + proto.STRING, + number=5, + ) + secret_type = proto.Field( + proto.STRING, + number=6, + ) + https_proxy = proto.Field( + proto.STRING, + number=7, + ) + gcp_service_account_email = proto.Field( + proto.STRING, + number=8, + ) + + +class PolicyController(proto.Message): + r"""Configuration for Policy Controller + Attributes: + enabled (bool): + Enables the installation of Policy + Controller. If false, the rest of + PolicyController fields take no effect. + template_library_installed (bool): + Installs the default template library along + with Policy Controller. + audit_interval_seconds (int): + Sets the interval for Policy Controller Audit + Scans (in seconds). When set to 0, this disables + audit functionality altogether. + exemptable_namespaces (Sequence[str]): + The set of namespaces that are excluded from + Policy Controller checks. Namespaces do not need + to currently exist on the cluster. + referential_rules_enabled (bool): + Enables the ability to use Constraint + Templates that reference to objects other than + the object currently being evaluated. + log_denies_enabled (bool): + Logs all denies and dry run failures. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + template_library_installed = proto.Field( + proto.BOOL, + number=2, + optional=True, + ) + audit_interval_seconds = proto.Field( + proto.INT64, + number=3, + optional=True, + ) + exemptable_namespaces = proto.RepeatedField( + proto.STRING, + number=4, + ) + referential_rules_enabled = proto.Field( + proto.BOOL, + number=5, + ) + log_denies_enabled = proto.Field( + proto.BOOL, + number=6, + ) + + +class HierarchyControllerConfig(proto.Message): + r"""Configuration for Hierarchy Controller + Attributes: + enabled (bool): + Whether Hierarchy Controller is enabled in + this cluster. + enable_pod_tree_labels (bool): + Whether pod tree labels are enabled in this + cluster. + enable_hierarchical_resource_quota (bool): + Whether hierarchical resource quota is + enabled in this cluster. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + enable_pod_tree_labels = proto.Field( + proto.BOOL, + number=2, + ) + enable_hierarchical_resource_quota = proto.Field( + proto.BOOL, + number=3, + ) + + +class HierarchyControllerDeploymentState(proto.Message): + r"""Deployment state for Hierarchy Controller + Attributes: + hnc (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + The deployment state for open source HNC + (e.g. v0.7.0-hc.0) + extension (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + The deployment state for Hierarchy Controller + extension (e.g. v0.7.0-hc.1) + """ + + hnc = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + extension = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + + +class HierarchyControllerVersion(proto.Message): + r"""Version for Hierarchy Controller + Attributes: + hnc (str): + Version for open source HNC + extension (str): + Version for Hierarchy Controller extension + """ + + hnc = proto.Field( + proto.STRING, + number=1, + ) + extension = proto.Field( + proto.STRING, + number=2, + ) + + +class HierarchyControllerState(proto.Message): + r"""State for Hierarchy Controller + Attributes: + version (google.cloud.gkehub.configmanagement_v1.types.HierarchyControllerVersion): + The version for Hierarchy Controller + state (google.cloud.gkehub.configmanagement_v1.types.HierarchyControllerDeploymentState): + The deployment state for Hierarchy Controller + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='HierarchyControllerVersion', + ) + state = proto.Field( + proto.MESSAGE, + number=2, + message='HierarchyControllerDeploymentState', + ) + + +class OperatorState(proto.Message): + r"""State information for an ACM's Operator + Attributes: + version (str): + The semenatic version number of the operator + deployment_state (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + The state of the Operator's deployment + errors (Sequence[google.cloud.gkehub.configmanagement_v1.types.InstallError]): + Install errors. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + deployment_state = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='InstallError', + ) + + +class InstallError(proto.Message): + r"""Errors pertaining to the installation of ACM + Attributes: + error_message (str): + A string representing the user facing error + message + """ + + error_message = proto.Field( + proto.STRING, + number=1, + ) + + +class ConfigSyncState(proto.Message): + r"""State information for ConfigSync + Attributes: + version (google.cloud.gkehub.configmanagement_v1.types.ConfigSyncVersion): + The version of ConfigSync deployed + deployment_state (google.cloud.gkehub.configmanagement_v1.types.ConfigSyncDeploymentState): + Information about the deployment of + ConfigSync, including the version of the various + Pods deployed + sync_state (google.cloud.gkehub.configmanagement_v1.types.SyncState): + The state of ConfigSync's process to sync + configs to a cluster + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSyncVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='ConfigSyncDeploymentState', + ) + sync_state = proto.Field( + proto.MESSAGE, + number=3, + message='SyncState', + ) + + +class ConfigSyncVersion(proto.Message): + r"""Specific versioning information pertaining to ConfigSync's + Pods + + Attributes: + importer (str): + Version of the deployed importer pod + syncer (str): + Version of the deployed syncer pod + git_sync (str): + Version of the deployed git-sync pod + monitor (str): + Version of the deployed monitor pod + reconciler_manager (str): + Version of the deployed reconciler-manager + pod + root_reconciler (str): + Version of the deployed reconciler container + in root-reconciler pod + """ + + importer = proto.Field( + proto.STRING, + number=1, + ) + syncer = proto.Field( + proto.STRING, + number=2, + ) + git_sync = proto.Field( + proto.STRING, + number=3, + ) + monitor = proto.Field( + proto.STRING, + number=4, + ) + reconciler_manager = proto.Field( + proto.STRING, + number=5, + ) + root_reconciler = proto.Field( + proto.STRING, + number=6, + ) + + +class ConfigSyncDeploymentState(proto.Message): + r"""The state of ConfigSync's deployment on a cluster + Attributes: + importer (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of the importer pod + syncer (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of the syncer pod + git_sync (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of the git-sync pod + monitor (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of the monitor pod + reconciler_manager (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of reconciler-manager pod + root_reconciler (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Deployment state of root-reconciler + """ + + importer = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + syncer = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + git_sync = proto.Field( + proto.ENUM, + number=3, + enum='DeploymentState', + ) + monitor = proto.Field( + proto.ENUM, + number=4, + enum='DeploymentState', + ) + reconciler_manager = proto.Field( + proto.ENUM, + number=5, + enum='DeploymentState', + ) + root_reconciler = proto.Field( + proto.ENUM, + number=6, + enum='DeploymentState', + ) + + +class SyncState(proto.Message): + r"""State indicating an ACM's progress syncing configurations to + a cluster + + Attributes: + source_token (str): + Token indicating the state of the repo. + import_token (str): + Token indicating the state of the importer. + sync_token (str): + Token indicating the state of the syncer. + last_sync (str): + Deprecated: use last_sync_time instead. Timestamp of when + ACM last successfully synced the repo The time format is + specified in https://golang.org/pkg/time/#Time.String + last_sync_time (google.protobuf.timestamp_pb2.Timestamp): + Timestamp type of when ACM last successfully + synced the repo + code (google.cloud.gkehub.configmanagement_v1.types.SyncState.SyncCode): + Sync status code + errors (Sequence[google.cloud.gkehub.configmanagement_v1.types.SyncError]): + A list of errors resulting from problematic + configs. This list will be truncated after 100 + errors, although it is unlikely for that many + errors to simultaneously exist. + """ + class SyncCode(proto.Enum): + r"""An enum representing an ACM's status syncing configs to a + cluster + """ + SYNC_CODE_UNSPECIFIED = 0 + SYNCED = 1 + PENDING = 2 + ERROR = 3 + NOT_CONFIGURED = 4 + NOT_INSTALLED = 5 + UNAUTHORIZED = 6 + UNREACHABLE = 7 + + source_token = proto.Field( + proto.STRING, + number=1, + ) + import_token = proto.Field( + proto.STRING, + number=2, + ) + sync_token = proto.Field( + proto.STRING, + number=3, + ) + last_sync = proto.Field( + proto.STRING, + number=4, + ) + last_sync_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + code = proto.Field( + proto.ENUM, + number=5, + enum=SyncCode, + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=6, + message='SyncError', + ) + + +class SyncError(proto.Message): + r"""An ACM created error representing a problem syncing + configurations + + Attributes: + code (str): + An ACM defined error code + error_message (str): + A description of the error + error_resources (Sequence[google.cloud.gkehub.configmanagement_v1.types.ErrorResource]): + A list of config(s) associated with the + error, if any + """ + + code = proto.Field( + proto.STRING, + number=1, + ) + error_message = proto.Field( + proto.STRING, + number=2, + ) + error_resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ErrorResource', + ) + + +class ErrorResource(proto.Message): + r"""Model for a config file in the git repo with an associated + Sync error + + Attributes: + source_path (str): + Path in the git repo of the erroneous config + resource_name (str): + Metadata name of the resource that is causing + an error + resource_namespace (str): + Namespace of the resource that is causing an + error + resource_gvk (google.cloud.gkehub.configmanagement_v1.types.GroupVersionKind): + Group/version/kind of the resource that is + causing an error + """ + + source_path = proto.Field( + proto.STRING, + number=1, + ) + resource_name = proto.Field( + proto.STRING, + number=2, + ) + resource_namespace = proto.Field( + proto.STRING, + number=3, + ) + resource_gvk = proto.Field( + proto.MESSAGE, + number=4, + message='GroupVersionKind', + ) + + +class GroupVersionKind(proto.Message): + r"""A Kubernetes object's GVK + Attributes: + group (str): + Kubernetes Group + version (str): + Kubernetes Version + kind (str): + Kubernetes Kind + """ + + group = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + kind = proto.Field( + proto.STRING, + number=3, + ) + + +class PolicyControllerState(proto.Message): + r"""State for PolicyControllerState. + Attributes: + version (google.cloud.gkehub.configmanagement_v1.types.PolicyControllerVersion): + The version of Gatekeeper Policy Controller + deployed. + deployment_state (google.cloud.gkehub.configmanagement_v1.types.GatekeeperDeploymentState): + The state about the policy controller + installation. + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='PolicyControllerVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='GatekeeperDeploymentState', + ) + + +class PolicyControllerVersion(proto.Message): + r"""The build version of Gatekeeper Policy Controller is using. + Attributes: + version (str): + The gatekeeper image tag that is composed of + ACM version, git tag, build number. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + + +class GatekeeperDeploymentState(proto.Message): + r"""State of Policy Controller installation. + Attributes: + gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Status of gatekeeper-controller-manager pod. + gatekeeper_audit (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): + Status of gatekeeper-audit deployment. + """ + + gatekeeper_controller_manager_state = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + gatekeeper_audit = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py new file mode 100644 index 0000000..2cf0ef2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.multiclusteringress_v1.types.multiclusteringress import FeatureSpec + +__all__ = ('FeatureSpec', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py new file mode 100644 index 0000000..e418f95 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.multiclusteringress import FeatureSpec + +__all__ = ( +'FeatureSpec', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json new file mode 100644 index 0000000..ad06970 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.multiclusteringress_v1", + "protoPackage": "google.cloud.gkehub.multiclusteringress.v1", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py new file mode 100644 index 0000000..03f4faa --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .multiclusteringress import ( + FeatureSpec, +) + +__all__ = ( + 'FeatureSpec', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py new file mode 100644 index 0000000..c6d0fff --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.multiclusteringress.v1', + manifest={ + 'FeatureSpec', + }, +) + + +class FeatureSpec(proto.Message): + r"""**Multi-cluster Ingress**: The configuration for the + MultiClusterIngress feature. + + Attributes: + config_membership (str): + Fully-qualified Membership name which hosts the + MultiClusterIngress CRD. Example: + ``projects/foo-proj/locations/global/memberships/bar`` + """ + + config_membership = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/py.typed b/owl-bot-staging/v1/google/cloud/gkehub/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py new file mode 100644 index 0000000..e699a81 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .services.gke_hub import GkeHubClient +from .services.gke_hub import GkeHubAsyncClient + +from .types.feature import CommonFeatureSpec +from .types.feature import CommonFeatureState +from .types.feature import Feature +from .types.feature import FeatureResourceState +from .types.feature import FeatureState +from .types.feature import MembershipFeatureSpec +from .types.feature import MembershipFeatureState +from .types.membership import Authority +from .types.membership import GkeCluster +from .types.membership import KubernetesMetadata +from .types.membership import Membership +from .types.membership import MembershipEndpoint +from .types.membership import MembershipState +from .types.service import ConnectAgentResource +from .types.service import CreateFeatureRequest +from .types.service import CreateMembershipRequest +from .types.service import DeleteFeatureRequest +from .types.service import DeleteMembershipRequest +from .types.service import GenerateConnectManifestRequest +from .types.service import GenerateConnectManifestResponse +from .types.service import GetFeatureRequest +from .types.service import GetMembershipRequest +from .types.service import ListFeaturesRequest +from .types.service import ListFeaturesResponse +from .types.service import ListMembershipsRequest +from .types.service import ListMembershipsResponse +from .types.service import OperationMetadata +from .types.service import TypeMeta +from .types.service import UpdateFeatureRequest +from .types.service import UpdateMembershipRequest + +__all__ = ( + 'GkeHubAsyncClient', +'Authority', +'CommonFeatureSpec', +'CommonFeatureState', +'ConnectAgentResource', +'CreateFeatureRequest', +'CreateMembershipRequest', +'DeleteFeatureRequest', +'DeleteMembershipRequest', +'Feature', +'FeatureResourceState', +'FeatureState', +'GenerateConnectManifestRequest', +'GenerateConnectManifestResponse', +'GetFeatureRequest', +'GetMembershipRequest', +'GkeCluster', +'GkeHubClient', +'KubernetesMetadata', +'ListFeaturesRequest', +'ListFeaturesResponse', +'ListMembershipsRequest', +'ListMembershipsResponse', +'Membership', +'MembershipEndpoint', +'MembershipFeatureSpec', +'MembershipFeatureState', +'MembershipState', +'OperationMetadata', +'TypeMeta', +'UpdateFeatureRequest', +'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json new file mode 100644 index 0000000..5086eae --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json @@ -0,0 +1,133 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub_v1", + "protoPackage": "google.cloud.gkehub.v1", + "schema": "1.0", + "services": { + "GkeHub": { + "clients": { + "grpc": { + "libraryClient": "GkeHubClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + } + } + }, + "grpc-async": { + "libraryClient": "GkeHubAsyncClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed b/owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py new file mode 100644 index 0000000..7304648 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .client import GkeHubClient +from .async_client import GkeHubAsyncClient + +__all__ = ( + 'GkeHubClient', + 'GkeHubAsyncClient', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py new file mode 100644 index 0000000..f986b07 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py @@ -0,0 +1,1211 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1.services.gke_hub import pagers +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport +from .client import GkeHubClient + + +class GkeHubAsyncClient: + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1.Membership] + - [Feature][google.cloud.gkehub.v1.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + _client: GkeHubClient + + DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT + + feature_path = staticmethod(GkeHubClient.feature_path) + parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) + membership_path = staticmethod(GkeHubClient.membership_path) + parse_membership_path = staticmethod(GkeHubClient.parse_membership_path) + common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + common_folder_path = staticmethod(GkeHubClient.common_folder_path) + parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) + common_organization_path = staticmethod(GkeHubClient.common_organization_path) + parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + common_project_path = staticmethod(GkeHubClient.common_project_path) + parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) + common_location_path = staticmethod(GkeHubClient.common_location_path) + parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = GkeHubClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_memberships(self, + request: service.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsAsyncPager: + r"""Lists Memberships in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1.types.ListMembershipsRequest`): + The request object. Request message for + `GkeHub.ListMemberships` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1.services.gke_hub.pagers.ListMembershipsAsyncPager: + Response message for the GkeHub.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListMembershipsRequest(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_memberships, + 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.ListMembershipsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: + r"""Lists Features in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1.types.ListFeaturesRequest`): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (:class:`str`): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1.services.gke_hub.pagers.ListFeaturesAsyncPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest(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_features, + 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.ListFeaturesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_membership(self, + request: service.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (:class:`google.cloud.gkehub_v1.types.GetMembershipRequest`): + The request object. Request message for + `GkeHub.GetMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetMembershipRequest(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_membership, + 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 get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (:class:`google.cloud.gkehub_v1.types.GetFeatureRequest`): + The request object. Request message for + `GkeHub.GetFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetFeatureRequest(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_feature, + 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 create_membership(self, + request: service.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To register other clusters, follow the instructions at + https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + + Args: + request (:class:`google.cloud.gkehub_v1.types.CreateMembershipRequest`): + The request object. Request message for the + `GkeHub.CreateMembership` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1.types.Membership`): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (:class:`str`): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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.CreateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds a new Feature. + + Args: + request (:class:`google.cloud.gkehub_v1.types.CreateFeatureRequest`): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (:class:`str`): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1.types.Feature`): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (:class:`str`): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Feature` Feature + represents the settings and status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_membership(self, + request: service.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To unregister other clusters, follow the instructions + at + https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + + Args: + request (:class:`google.cloud.gkehub_v1.types.DeleteMembershipRequest`): + The request object. Request message for + `GkeHub.DeleteMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteMembershipRequest(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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Feature. + + Args: + request (:class:`google.cloud.gkehub_v1.types.DeleteFeatureRequest`): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteFeatureRequest(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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_membership(self, + request: service.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Membership. + + Args: + request (:class:`google.cloud.gkehub_v1.types.UpdateMembershipRequest`): + The request object. Request message for + `GkeHub.UpdateMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1.types.Membership`): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. If you specify the update_mask to be a special + path "*", fully replaces all user-modifiable fields to + match ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Mask of fields to update. + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Feature. + + Args: + request (:class:`google.cloud.gkehub_v1.types.UpdateFeatureRequest`): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1.types.Feature`): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Mask of fields to update. + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Feature` Feature + represents the settings and status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def generate_connect_manifest(self, + request: service.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE connect agent. + + **This method is used internally by Google-provided libraries.** + Most clients should not need to call this method directly. + + Args: + request (:class:`google.cloud.gkehub_v1.types.GenerateConnectManifestRequest`): + The request object. Request message for + `GkeHub.GenerateConnectManifest` method. + . + 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.gkehub_v1.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + request = service.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.generate_connect_manifest, + 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 + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubAsyncClient", +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py new file mode 100644 index 0000000..85ddb7e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py @@ -0,0 +1,1408 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1.services.gke_hub import pagers +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import GkeHubGrpcTransport +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +class GkeHubClientMeta(type): + """Metaclass for the GkeHub client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] + _transport_registry["grpc"] = GkeHubGrpcTransport + _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[GkeHubTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class GkeHubClient(metaclass=GkeHubClientMeta): + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1.Membership] + - [Feature][google.cloud.gkehub.v1.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "gkehub.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def feature_path(project: str,location: str,feature: str,) -> str: + """Returns a fully-qualified feature string.""" + return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + + @staticmethod + def parse_feature_path(path: str) -> Dict[str,str]: + """Parses a feature path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def membership_path(project: str,location: str,membership: str,) -> str: + """Returns a fully-qualified membership string.""" + return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + + @staticmethod + def parse_membership_path(path: str) -> Dict[str,str]: + """Parses a membership path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?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, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + 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, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, GkeHubTransport): + # transport is a GkeHubTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def list_memberships(self, + request: service.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsPager: + r"""Lists Memberships in a given project and location. + + Args: + request (google.cloud.gkehub_v1.types.ListMembershipsRequest): + The request object. Request message for + `GkeHub.ListMemberships` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1.services.gke_hub.pagers.ListMembershipsPager: + Response message for the GkeHub.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListMembershipsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListMembershipsRequest): + request = service.ListMembershipsRequest(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_memberships] + + # 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.ListMembershipsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: + r"""Lists Features in a given project and location. + + Args: + request (google.cloud.gkehub_v1.types.ListFeaturesRequest): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (str): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1.services.gke_hub.pagers.ListFeaturesPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListFeaturesRequest): + request = service.ListFeaturesRequest(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_features] + + # 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.ListFeaturesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_membership(self, + request: service.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (google.cloud.gkehub_v1.types.GetMembershipRequest): + The request object. Request message for + `GkeHub.GetMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetMembershipRequest): + request = service.GetMembershipRequest(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_membership] + + # 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 get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (google.cloud.gkehub_v1.types.GetFeatureRequest): + The request object. Request message for + `GkeHub.GetFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetFeatureRequest): + request = service.GetFeatureRequest(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_feature] + + # 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 create_membership(self, + request: service.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To register other clusters, follow the instructions at + https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + + Args: + request (google.cloud.gkehub_v1.types.CreateMembershipRequest): + The request object. Request message for the + `GkeHub.CreateMembership` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1.types.Membership): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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.CreateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateMembershipRequest): + request = service.CreateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_membership] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds a new Feature. + + Args: + request (google.cloud.gkehub_v1.types.CreateFeatureRequest): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (str): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1.types.Feature): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (str): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Feature` Feature + represents the settings and status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateFeatureRequest): + request = service.CreateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_feature] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_membership(self, + request: service.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To unregister other clusters, follow the instructions + at + https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + + Args: + request (google.cloud.gkehub_v1.types.DeleteMembershipRequest): + The request object. Request message for + `GkeHub.DeleteMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteMembershipRequest): + request = service.DeleteMembershipRequest(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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Feature. + + Args: + request (google.cloud.gkehub_v1.types.DeleteFeatureRequest): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteFeatureRequest): + request = service.DeleteFeatureRequest(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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_membership(self, + request: service.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Membership. + + Args: + request (google.cloud.gkehub_v1.types.UpdateMembershipRequest): + The request object. Request message for + `GkeHub.UpdateMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1.types.Membership): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. If you specify the update_mask to be a special + path "*", fully replaces all user-modifiable fields to + match ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateMembershipRequest): + request = service.UpdateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Feature. + + Args: + request (google.cloud.gkehub_v1.types.UpdateFeatureRequest): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1.types.Feature` Feature + represents the settings and status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateFeatureRequest): + request = service.UpdateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def generate_connect_manifest(self, + request: service.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE connect agent. + + **This method is used internally by Google-provided libraries.** + Most clients should not need to call this method directly. + + Args: + request (google.cloud.gkehub_v1.types.GenerateConnectManifestRequest): + The request object. Request message for + `GkeHub.GenerateConnectManifest` method. + . + 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.gkehub_v1.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.GenerateConnectManifestRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GenerateConnectManifestRequest): + request = service.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] + + # 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 + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubClient", +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py new file mode 100644 index 0000000..57d56bc --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py @@ -0,0 +1,264 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service + + +class ListMembershipsPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1.types.ListMembershipsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1.types.ListMembershipsResponse` + 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.ListMembershipsResponse], + request: service.ListMembershipsRequest, + response: service.ListMembershipsResponse, + *, + 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.gkehub_v1.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1.types.ListMembershipsResponse): + 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.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListMembershipsResponse]: + 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) -> Iterable[membership.Membership]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListMembershipsAsyncPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1.types.ListMembershipsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1.types.ListMembershipsResponse` + 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.ListMembershipsResponse]], + request: service.ListMembershipsRequest, + response: service.ListMembershipsResponse, + *, + 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.gkehub_v1.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1.types.ListMembershipsResponse): + 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.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListMembershipsResponse]: + 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) -> AsyncIterable[membership.Membership]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFeaturesPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1.types.ListFeaturesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1.types.ListFeaturesResponse` + 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.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListFeaturesResponse]: + 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) -> Iterable[feature.Feature]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFeaturesAsyncPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1.types.ListFeaturesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1.types.ListFeaturesResponse` + 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.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListFeaturesResponse]: + 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) -> AsyncIterable[feature.Feature]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py new file mode 100644 index 0000000..29c1c45 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import GkeHubTransport +from .grpc import GkeHubGrpcTransport +from .grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] +_transport_registry['grpc'] = GkeHubGrpcTransport +_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport + +__all__ = ( + 'GkeHubTransport', + 'GkeHubGrpcTransport', + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py new file mode 100644 index 0000000..5b6c731 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py @@ -0,0 +1,317 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-gke-hub', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class GkeHubTransport(abc.ABC): + """Abstract transport class for GkeHub.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'gkehub.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + 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' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_memberships: gapic_v1.method.wrap_method( + self.list_memberships, + default_timeout=None, + client_info=client_info, + ), + self.list_features: gapic_v1.method.wrap_method( + self.list_features, + default_timeout=None, + client_info=client_info, + ), + self.get_membership: gapic_v1.method.wrap_method( + self.get_membership, + default_timeout=None, + client_info=client_info, + ), + self.get_feature: gapic_v1.method.wrap_method( + self.get_feature, + default_timeout=None, + client_info=client_info, + ), + self.create_membership: gapic_v1.method.wrap_method( + self.create_membership, + default_timeout=None, + client_info=client_info, + ), + self.create_feature: gapic_v1.method.wrap_method( + self.create_feature, + default_timeout=None, + client_info=client_info, + ), + self.delete_membership: gapic_v1.method.wrap_method( + self.delete_membership, + default_timeout=None, + client_info=client_info, + ), + self.delete_feature: gapic_v1.method.wrap_method( + self.delete_feature, + default_timeout=None, + client_info=client_info, + ), + self.update_membership: gapic_v1.method.wrap_method( + self.update_membership, + default_timeout=None, + client_info=client_info, + ), + self.update_feature: gapic_v1.method.wrap_method( + self.update_feature, + default_timeout=None, + client_info=client_info, + ), + self.generate_connect_manifest: gapic_v1.method.wrap_method( + self.generate_connect_manifest, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_memberships(self) -> Callable[ + [service.ListMembershipsRequest], + Union[ + service.ListMembershipsResponse, + Awaitable[service.ListMembershipsResponse] + ]]: + raise NotImplementedError() + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Union[ + service.ListFeaturesResponse, + Awaitable[service.ListFeaturesResponse] + ]]: + raise NotImplementedError() + + @property + def get_membership(self) -> Callable[ + [service.GetMembershipRequest], + Union[ + membership.Membership, + Awaitable[membership.Membership] + ]]: + raise NotImplementedError() + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Union[ + feature.Feature, + Awaitable[feature.Feature] + ]]: + raise NotImplementedError() + + @property + def create_membership(self) -> Callable[ + [service.CreateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_membership(self) -> Callable[ + [service.DeleteMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_membership(self) -> Callable[ + [service.UpdateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def generate_connect_manifest(self) -> Callable[ + [service.GenerateConnectManifestRequest], + Union[ + service.GenerateConnectManifestResponse, + Awaitable[service.GenerateConnectManifestResponse] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'GkeHubTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py new file mode 100644 index 0000000..6866dd8 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py @@ -0,0 +1,555 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO + + +class GkeHubGrpcTransport(GkeHubTransport): + """gRPC backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1.Membership] + - [Feature][google.cloud.gkehub.v1.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [service.ListMembershipsRequest], + service.ListMembershipsResponse]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + ~.ListMembershipsResponse]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/ListMemberships', + request_serializer=service.ListMembershipsRequest.serialize, + response_deserializer=service.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + service.ListFeaturesResponse]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + ~.ListFeaturesResponse]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_membership(self) -> Callable[ + [service.GetMembershipRequest], + membership.Membership]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + ~.Membership]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GetMembership', + request_serializer=service.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + feature.Feature]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + ~.Feature]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_membership(self) -> Callable[ + [service.CreateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the create membership method over gRPC. + + Creates a new Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To register other clusters, follow the instructions at + https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + + Returns: + Callable[[~.CreateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/CreateMembership', + request_serializer=service.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_membership(self) -> Callable[ + [service.DeleteMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To unregister other clusters, follow the instructions + at + https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + + Returns: + Callable[[~.DeleteMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/DeleteMembership', + request_serializer=service.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_membership(self) -> Callable[ + [service.UpdateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/UpdateMembership', + request_serializer=service.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + @property + def generate_connect_manifest(self) -> Callable[ + [service.GenerateConnectManifestRequest], + service.GenerateConnectManifestResponse]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE connect agent. + + **This method is used internally by Google-provided libraries.** + Most clients should not need to call this method directly. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + ~.GenerateConnectManifestResponse]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest', + request_serializer=service.GenerateConnectManifestRequest.serialize, + response_deserializer=service.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + +__all__ = ( + 'GkeHubGrpcTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py new file mode 100644 index 0000000..ad6ddc2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py @@ -0,0 +1,559 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .grpc import GkeHubGrpcTransport + + +class GkeHubGrpcAsyncIOTransport(GkeHubTransport): + """gRPC AsyncIO backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1.Membership] + - [Feature][google.cloud.gkehub.v1.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [service.ListMembershipsRequest], + Awaitable[service.ListMembershipsResponse]]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + Awaitable[~.ListMembershipsResponse]]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/ListMemberships', + request_serializer=service.ListMembershipsRequest.serialize, + response_deserializer=service.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Awaitable[service.ListFeaturesResponse]]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + Awaitable[~.ListFeaturesResponse]]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_membership(self) -> Callable[ + [service.GetMembershipRequest], + Awaitable[membership.Membership]]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + Awaitable[~.Membership]]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GetMembership', + request_serializer=service.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Awaitable[feature.Feature]]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + Awaitable[~.Feature]]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_membership(self) -> Callable[ + [service.CreateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create membership method over gRPC. + + Creates a new Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To register other clusters, follow the instructions at + https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + + Returns: + Callable[[~.CreateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/CreateMembership', + request_serializer=service.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_membership(self) -> Callable[ + [service.DeleteMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + **This is currently only supported for GKE clusters on Google + Cloud**. To unregister other clusters, follow the instructions + at + https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + + Returns: + Callable[[~.DeleteMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/DeleteMembership', + request_serializer=service.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_membership(self) -> Callable[ + [service.UpdateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/UpdateMembership', + request_serializer=service.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + @property + def generate_connect_manifest(self) -> Callable[ + [service.GenerateConnectManifestRequest], + Awaitable[service.GenerateConnectManifestResponse]]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE connect agent. + + **This method is used internally by Google-provided libraries.** + Most clients should not need to call this method directly. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + Awaitable[~.GenerateConnectManifestResponse]]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest', + request_serializer=service.GenerateConnectManifestRequest.serialize, + response_deserializer=service.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + +__all__ = ( + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py new file mode 100644 index 0000000..e12ea53 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .feature import ( + CommonFeatureSpec, + CommonFeatureState, + Feature, + FeatureResourceState, + FeatureState, + MembershipFeatureSpec, + MembershipFeatureState, +) +from .membership import ( + Authority, + GkeCluster, + KubernetesMetadata, + Membership, + MembershipEndpoint, + MembershipState, +) +from .service import ( + ConnectAgentResource, + CreateFeatureRequest, + CreateMembershipRequest, + DeleteFeatureRequest, + DeleteMembershipRequest, + GenerateConnectManifestRequest, + GenerateConnectManifestResponse, + GetFeatureRequest, + GetMembershipRequest, + ListFeaturesRequest, + ListFeaturesResponse, + ListMembershipsRequest, + ListMembershipsResponse, + OperationMetadata, + TypeMeta, + UpdateFeatureRequest, + UpdateMembershipRequest, +) + +__all__ = ( + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'Authority', + 'GkeCluster', + 'KubernetesMetadata', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'ConnectAgentResource', + 'CreateFeatureRequest', + 'CreateMembershipRequest', + 'DeleteFeatureRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GetFeatureRequest', + 'GetMembershipRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'OperationMetadata', + 'TypeMeta', + 'UpdateFeatureRequest', + 'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py new file mode 100644 index 0000000..d9aea6e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py @@ -0,0 +1,294 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub.configmanagement.v1 import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1 import multiclusteringress_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1', + manifest={ + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + }, +) + + +class Feature(proto.Message): + r"""Feature represents the settings and status of any Hub + Feature. + + Attributes: + name (str): + Output only. The full, unique name of this Feature resource + in the format ``projects/*/locations/*/features/*``. + labels (Sequence[google.cloud.gkehub_v1.types.Feature.LabelsEntry]): + GCP labels for this Feature. + resource_state (google.cloud.gkehub_v1.types.FeatureResourceState): + Output only. State of the Feature resource + itself. + spec (google.cloud.gkehub_v1.types.CommonFeatureSpec): + Optional. Hub-wide Feature configuration. If + this Feature does not support any Hub-wide + configuration, this field may be unused. + membership_specs (Sequence[google.cloud.gkehub_v1.types.Feature.MembershipSpecsEntry]): + Optional. Membership-specific configuration + for this Feature. If this Feature does not + support any per-Membership configuration, this + field may be unused. + The keys indicate which Membership the + configuration is for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} WILL match the + Feature's project. + + {p} will always be returned as the project + number, but the project ID is also accepted + during input. If the same Membership is + specified in the map twice (using the project ID + form, and the project number form), exactly ONE + of the entries will be saved, with no guarantees + as to which. For this reason, it is recommended + the same format be used for all entries when + mutating a Feature. + state (google.cloud.gkehub_v1.types.CommonFeatureState): + Output only. The Hub-wide Feature state. + membership_states (Sequence[google.cloud.gkehub_v1.types.Feature.MembershipStatesEntry]): + Output only. Membership-specific Feature + status. If this Feature does report any per- + Membership status, this field may be unused. + The keys indicate which Membership the state is + for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project number, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} MUST match the + Feature's project number. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + last updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + deleted. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + resource_state = proto.Field( + proto.MESSAGE, + number=3, + message='FeatureResourceState', + ) + spec = proto.Field( + proto.MESSAGE, + number=4, + message='CommonFeatureSpec', + ) + membership_specs = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=5, + message='MembershipFeatureSpec', + ) + state = proto.Field( + proto.MESSAGE, + number=6, + message='CommonFeatureState', + ) + membership_states = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=7, + message='MembershipFeatureState', + ) + create_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, + ) + + +class FeatureResourceState(proto.Message): + r"""FeatureResourceState describes the state of a Feature *resource* in + the GkeHub API. See ``FeatureState`` for the "running state" of the + Feature in the Hub and across Memberships. + + Attributes: + state (google.cloud.gkehub_v1.types.FeatureResourceState.State): + The current state of the Feature resource in + the Hub API. + """ + class State(proto.Enum): + r"""State describes the lifecycle status of a Feature.""" + STATE_UNSPECIFIED = 0 + ENABLING = 1 + ACTIVE = 2 + DISABLING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + + +class FeatureState(proto.Message): + r"""FeatureState describes the high-level state of a Feature. It + may be used to describe a Feature's state at the environ-level, + or per-membershop, depending on the context. + + Attributes: + code (google.cloud.gkehub_v1.types.FeatureState.Code): + The high-level, machine-readable status of + this Feature. + description (str): + A human-readable description of the current + status. + update_time (google.protobuf.timestamp_pb2.Timestamp): + The time this status and any related Feature- + pecific details were updated. + """ + class Code(proto.Enum): + r"""Code represents a machine-readable, high-level status of the + Feature. + """ + CODE_UNSPECIFIED = 0 + OK = 1 + WARNING = 2 + ERROR = 3 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + + +class CommonFeatureSpec(proto.Message): + r"""CommonFeatureSpec contains Hub-wide configuration information + Attributes: + multiclusteringress (google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2.FeatureSpec): + Multicluster Ingress-specific spec. + """ + + multiclusteringress = proto.Field( + proto.MESSAGE, + number=102, + oneof='feature_spec', + message=multiclusteringress_pb2.FeatureSpec, + ) + + +class CommonFeatureState(proto.Message): + r"""CommonFeatureState contains Hub-wide Feature status + information. + + Attributes: + state (google.cloud.gkehub_v1.types.FeatureState): + Output only. The "running state" of the + Feature in this Hub. + """ + + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +class MembershipFeatureSpec(proto.Message): + r"""MembershipFeatureSpec contains configuration information for + a single Membership. + + Attributes: + configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipSpec): + Config Management-specific spec. + """ + + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_spec', + message=configmanagement_pb2.MembershipSpec, + ) + + +class MembershipFeatureState(proto.Message): + r"""MembershipFeatureState contains Feature status information + for a single Membership. + + Attributes: + configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipState): + Config Management-specific state. + state (google.cloud.gkehub_v1.types.FeatureState): + The high-level state of this Feature for a + single membership. + """ + + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_state', + message=configmanagement_pb2.MembershipState, + ) + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py new file mode 100644 index 0000000..147fd51 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py @@ -0,0 +1,349 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1', + manifest={ + 'Membership', + 'MembershipEndpoint', + 'GkeCluster', + 'KubernetesMetadata', + 'MembershipState', + 'Authority', + }, +) + + +class Membership(proto.Message): + r"""Membership contains information about a member cluster. + Attributes: + endpoint (google.cloud.gkehub_v1.types.MembershipEndpoint): + Optional. Endpoint information to reach this + member. + name (str): + Output only. The full, unique name of this Membership + resource in the format + ``projects/*/locations/*/memberships/{membership_id}``, set + during creation. + + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + labels (Sequence[google.cloud.gkehub_v1.types.Membership.LabelsEntry]): + Optional. GCP labels for this membership. + description (str): + Output only. Description of this membership, limited to 63 + characters. Must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.\ ]*`` + + This field is present for legacy purposes. + state (google.cloud.gkehub_v1.types.MembershipState): + Output only. State of the Membership + resource. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was last + updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was deleted. + external_id (str): + Optional. An externally-generated and managed ID for this + Membership. This ID may be modified after creation, but this + is not recommended. + + The ID must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.]*`` + + If this Membership represents a Kubernetes cluster, this + value should be set to the UID of the ``kube-system`` + namespace object. + last_connection_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. For clusters using Connect, the + timestamp of the most recent connection + established with Google Cloud. This time is + updated every several minutes, not continuously. + For clusters that do not use GKE Connect, or + that have never connected successfully, this + field will be unset. + unique_id (str): + Output only. Google-generated UUID for this resource. This + is unique across all Membership resources. If a Membership + resource is deleted and another resource with the same name + is created, it gets a different unique_id. + authority (google.cloud.gkehub_v1.types.Authority): + Optional. How to identify workloads from this + Membership. See the documentation on Workload + Identity for more details: + https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + """ + + endpoint = proto.Field( + proto.MESSAGE, + number=4, + oneof='type', + message='MembershipEndpoint', + ) + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + description = proto.Field( + proto.STRING, + number=3, + ) + state = proto.Field( + proto.MESSAGE, + number=5, + message='MembershipState', + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + external_id = proto.Field( + proto.STRING, + number=9, + ) + last_connection_time = proto.Field( + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, + ) + unique_id = proto.Field( + proto.STRING, + number=11, + ) + authority = proto.Field( + proto.MESSAGE, + number=12, + message='Authority', + ) + + +class MembershipEndpoint(proto.Message): + r"""MembershipEndpoint contains information needed to contact a + Kubernetes API, endpoint and any additional Kubernetes metadata. + + Attributes: + gke_cluster (google.cloud.gkehub_v1.types.GkeCluster): + Optional. GKE-specific information. Only + present if this Membership is a GKE cluster. + kubernetes_metadata (google.cloud.gkehub_v1.types.KubernetesMetadata): + Output only. Useful Kubernetes-specific + metadata. + """ + + gke_cluster = proto.Field( + proto.MESSAGE, + number=1, + message='GkeCluster', + ) + kubernetes_metadata = proto.Field( + proto.MESSAGE, + number=2, + message='KubernetesMetadata', + ) + + +class GkeCluster(proto.Message): + r"""GkeCluster contains information specific to GKE clusters. + Attributes: + resource_link (str): + Immutable. Self-link of the GCP resource for + the GKE cluster. For example: + //container.googleapis.com/projects/my- + project/locations/us-west1-a/clusters/my-cluster + Zonal clusters are also supported. + """ + + resource_link = proto.Field( + proto.STRING, + number=1, + ) + + +class KubernetesMetadata(proto.Message): + r"""KubernetesMetadata provides informational metadata for + Memberships representing Kubernetes clusters. + + Attributes: + kubernetes_api_server_version (str): + Output only. Kubernetes API server version string as + reported by ``/version``. + node_provider_id (str): + Output only. Node providerID as reported by the first node + in the list of nodes on the Kubernetes endpoint. On + Kubernetes platforms that support zero-node clusters (like + GKE-on-GCP), the node_count will be zero and the + node_provider_id will be empty. + node_count (int): + Output only. Node count as reported by + Kubernetes nodes resources. + vcpu_count (int): + Output only. vCPU count as reported by + Kubernetes nodes resources. + memory_mb (int): + Output only. The total memory capacity as + reported by the sum of all Kubernetes nodes + resources, defined in MB. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which these details were last + updated. This update_time is different from the + Membership-level update_time since EndpointDetails are + updated internally for API consumers. + """ + + kubernetes_api_server_version = proto.Field( + proto.STRING, + number=1, + ) + node_provider_id = proto.Field( + proto.STRING, + number=2, + ) + node_count = proto.Field( + proto.INT32, + number=3, + ) + vcpu_count = proto.Field( + proto.INT32, + number=4, + ) + memory_mb = proto.Field( + proto.INT32, + number=5, + ) + update_time = proto.Field( + proto.MESSAGE, + number=100, + message=timestamp_pb2.Timestamp, + ) + + +class MembershipState(proto.Message): + r"""MembershipState describes the state of a Membership resource. + Attributes: + code (google.cloud.gkehub_v1.types.MembershipState.Code): + Output only. The current state of the + Membership resource. + """ + class Code(proto.Enum): + r"""Code describes the state of a Membership resource.""" + CODE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + + +class Authority(proto.Message): + r"""Authority encodes how Google will recognize identities from + this Membership. See the workload identity documentation for + more details: https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + + Attributes: + issuer (str): + Optional. A JSON Web Token (JWT) issuer URI. ``issuer`` must + start with ``https://`` and be a valid URL with length <2000 + characters. + + If set, then Google will allow valid OIDC tokens from this + issuer to authenticate within the workload_identity_pool. + OIDC discovery will be performed on this URI to validate + tokens from the issuer. + + Clearing ``issuer`` disables Workload Identity. ``issuer`` + cannot be directly modified; it must be cleared (and + Workload Identity disabled) before using a new issuer (and + re-enabling Workload Identity). + workload_identity_pool (str): + Output only. The name of the workload identity pool in which + ``issuer`` will be recognized. + + There is a single Workload Identity Pool per Hub that is + shared between all Memberships that belong to that Hub. For + a Hub hosted in {PROJECT_ID}, the workload pool format is + ``{PROJECT_ID}.hub.id.goog``, although this is subject to + change in newer versions of this API. + identity_provider (str): + Output only. An identity provider that reflects the + ``issuer`` in the workload identity pool. + oidc_jwks (bytes): + Optional. OIDC verification keys for this Membership in JWKS + format (RFC 7517). + + When this field is set, OIDC discovery will NOT be performed + on ``issuer``, and instead OIDC tokens will be validated + using this field. + """ + + issuer = proto.Field( + proto.STRING, + number=1, + ) + workload_identity_pool = proto.Field( + proto.STRING, + number=2, + ) + identity_provider = proto.Field( + proto.STRING, + number=3, + ) + oidc_jwks = proto.Field( + proto.BYTES, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py new file mode 100644 index 0000000..d777913 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py @@ -0,0 +1,758 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1', + manifest={ + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'GetMembershipRequest', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'UpdateMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'ConnectAgentResource', + 'TypeMeta', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'GetFeatureRequest', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'UpdateFeatureRequest', + 'OperationMetadata', + }, +) + + +class ListMembershipsRequest(proto.Message): + r"""Request message for ``GkeHub.ListMemberships`` method. + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/locations/*``. + page_size (int): + Optional. When requesting a 'page' of resources, + ``page_size`` specifies number of resources to return. If + unspecified or set to 0, all resources will be returned. + page_token (str): + Optional. Token returned by previous call to + ``ListMemberships`` which specifies the position in the list + from where to continue listing the resources. + filter (str): + Optional. Lists Memberships that match the filter + expression, following the syntax outlined in + https://google.aip.dev/160. + + Examples: + + - Name is ``bar`` in project ``foo-proj`` and location + ``global``: + + name = + "projects/foo-proj/locations/global/membership/bar" + + - Memberships that have a label called ``foo``: + + labels.foo:\* + + - Memberships that have a label called ``foo`` whose value + is ``bar``: + + labels.foo = bar + + - Memberships in the CREATING state: + + state = CREATING + order_by (str): + Optional. One or more fields to compare and + use to sort the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListMembershipsResponse(proto.Message): + r"""Response message for the ``GkeHub.ListMemberships`` method. + Attributes: + resources (Sequence[google.cloud.gkehub_v1.types.Membership]): + The list of matching Memberships. + next_page_token (str): + A token to request the next page of resources from the + ``ListMemberships`` method. The value of an empty string + means that there are no more resources to return. + unreachable (Sequence[str]): + List of locations that could not be reached + while fetching this list. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=membership.Membership, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.GetMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateMembershipRequest(proto.Message): + r"""Request message for the ``GkeHub.CreateMembership`` method. + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + resource (google.cloud.gkehub_v1.types.Membership): + Required. The membership to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + membership_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=membership.Membership, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DeleteMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.DeleteMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.UpdateMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + resource (google.cloud.gkehub_v1.types.Membership): + Required. Only fields specified in update_mask are updated. + If you specify a field in the update_mask but don't specify + its value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If you + specify the update_mask to be a special path "*", fully + replaces all user-modifiable fields to match ``resource``. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=membership.Membership, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class GenerateConnectManifestRequest(proto.Message): + r"""Request message for ``GkeHub.GenerateConnectManifest`` method. . + Attributes: + name (str): + Required. The Membership resource name the Agent will + associate with, in the format + ``projects/*/locations/*/memberships/*``. + namespace (str): + Optional. Namespace for GKE Connect agent resources. + Defaults to ``gke-connect``. + + The Connect Agent is authorized automatically when run in + the default namespace. Otherwise, explicit authorization + must be granted with an additional IAM binding. + proxy (bytes): + Optional. URI of a proxy if connectivity from the agent to + gkeconnect.googleapis.com requires the use of a proxy. + Format must be in the form ``http(s)://{proxy_address}``, + depending on the HTTP/HTTPS protocol supported by the proxy. + This will direct the connect agent's outbound traffic + through a HTTP(S) proxy. + version (str): + Optional. The Connect agent version to use. + Defaults to the most current version. + is_upgrade (bool): + Optional. If true, generate the resources for + upgrade only. Some resources generated only for + installation (e.g. secrets) will be excluded. + registry (str): + Optional. The registry to fetch the connect + agent image from. Defaults to gcr.io/gkeconnect. + image_pull_secret_content (bytes): + Optional. The image pull secret content for + the registry, if not public. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + namespace = proto.Field( + proto.STRING, + number=2, + ) + proxy = proto.Field( + proto.BYTES, + number=3, + ) + version = proto.Field( + proto.STRING, + number=4, + ) + is_upgrade = proto.Field( + proto.BOOL, + number=5, + ) + registry = proto.Field( + proto.STRING, + number=6, + ) + image_pull_secret_content = proto.Field( + proto.BYTES, + number=7, + ) + + +class GenerateConnectManifestResponse(proto.Message): + r"""GenerateConnectManifestResponse contains manifest information + for installing/upgrading a Connect agent. + + Attributes: + manifest (Sequence[google.cloud.gkehub_v1.types.ConnectAgentResource]): + The ordered list of Kubernetes resources that + need to be applied to the cluster for GKE + Connect agent installation/upgrade. + """ + + manifest = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='ConnectAgentResource', + ) + + +class ConnectAgentResource(proto.Message): + r"""ConnectAgentResource represents a Kubernetes resource + manifest for Connect Agent deployment. + + Attributes: + type_ (google.cloud.gkehub_v1.types.TypeMeta): + Kubernetes type of the resource. + manifest (str): + YAML manifest of the resource. + """ + + type_ = proto.Field( + proto.MESSAGE, + number=1, + message='TypeMeta', + ) + manifest = proto.Field( + proto.STRING, + number=2, + ) + + +class TypeMeta(proto.Message): + r"""TypeMeta is the type information needed for content + unmarshalling of Kubernetes resources in the manifest. + + Attributes: + kind (str): + Kind of the resource (e.g. Deployment). + api_version (str): + APIVersion of the resource (e.g. v1). + """ + + kind = proto.Field( + proto.STRING, + number=1, + ) + api_version = proto.Field( + proto.STRING, + number=2, + ) + + +class ListFeaturesRequest(proto.Message): + r"""Request message for ``GkeHub.ListFeatures`` method. + Attributes: + parent (str): + The parent (project and location) where the Features will be + listed. Specified in the format ``projects/*/locations/*``. + page_size (int): + When requesting a 'page' of resources, ``page_size`` + specifies number of resources to return. If unspecified or + set to 0, all resources will be returned. + page_token (str): + Token returned by previous call to ``ListFeatures`` which + specifies the position in the list from where to continue + listing the resources. + filter (str): + Lists Features that match the filter expression, following + the syntax outlined in https://google.aip.dev/160. + + Examples: + + - Feature with the name "servicemesh" in project + "foo-proj": + + name = + "projects/foo-proj/locations/global/features/servicemesh" + + - Features that have a label called ``foo``: + + labels.foo:\* + + - Features that have a label called ``foo`` whose value is + ``bar``: + + labels.foo = bar + order_by (str): + One or more fields to compare and use to sort + the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListFeaturesResponse(proto.Message): + r"""Response message for the ``GkeHub.ListFeatures`` method. + Attributes: + resources (Sequence[google.cloud.gkehub_v1.types.Feature]): + The list of matching Features + next_page_token (str): + A token to request the next page of resources from the + ``ListFeatures`` method. The value of an empty string means + that there are no more resources to return. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=feature.Feature, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.GetFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateFeatureRequest(proto.Message): + r"""Request message for the ``GkeHub.CreateFeature`` method. + Attributes: + parent (str): + The parent (project and location) where the Feature will be + created. Specified in the format ``projects/*/locations/*``. + feature_id (str): + The ID of the feature to create. + resource (google.cloud.gkehub_v1.types.Feature): + The Feature resource to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + feature_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DeleteFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.DeleteFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + force (bool): + If set to true, the delete will ignore any outstanding + resources for this Feature (that is, + ``FeatureState.has_resources`` is set to true). These + resources will NOT be cleaned up or modified in any way. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + force = proto.Field( + proto.BOOL, + number=2, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.UpdateFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + resource (google.cloud.gkehub_v1.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are updating a + map field, set the value of a key to null or empty string to + delete the key from the map. It's not possible to update a + key's value to the empty string. If you specify the + update_mask to be a special path "*", fully replaces all + user-modifiable fields to match ``resource``. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_detail (str): + Output only. Human-readable status of the + operation, if any. + cancel_requested (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/mypy.ini b/owl-bot-staging/v1/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1/noxfile.py b/owl-bot-staging/v1/noxfile.py new file mode 100644 index 0000000..7a7b5ac --- /dev/null +++ b/owl-bot-staging/v1/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/gkehub/multiclusteringress_v1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py new file mode 100644 index 0000000..b06f1d0 --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class configmanagementCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=configmanagementCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the configmanagement client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py new file mode 100644 index 0000000..a8a2a9b --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py @@ -0,0 +1,186 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class gkehubCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_feature': ('parent', 'feature_id', 'resource', 'request_id', ), + 'create_membership': ('parent', 'membership_id', 'resource', 'request_id', ), + 'delete_feature': ('name', 'force', 'request_id', ), + 'delete_membership': ('name', 'request_id', ), + 'generate_connect_manifest': ('name', 'namespace', 'proxy', 'version', 'is_upgrade', 'registry', 'image_pull_secret_content', ), + 'get_feature': ('name', ), + 'get_membership': ('name', ), + 'list_features': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_memberships': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_feature': ('name', 'update_mask', 'resource', 'request_id', ), + 'update_membership': ('name', 'update_mask', 'resource', 'request_id', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=gkehubCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the gkehub client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py new file mode 100644 index 0000000..e15ebbc --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class multiclusteringressCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=multiclusteringressCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the multiclusteringress client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1/setup.py b/owl-bot-staging/v1/setup.py new file mode 100644 index 0000000..e2e8ad3 --- /dev/null +++ b/owl-bot-staging/v1/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-gkehub-multiclusteringress', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1/tests/__init__.py b/owl-bot-staging/v1/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/tests/unit/__init__.py b/owl-bot-staging/v1/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py b/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py new file mode 100644 index 0000000..87c99c6 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py @@ -0,0 +1,3883 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +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 operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.gkehub.configmanagement.v1 import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1 import multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub_v1.services.gke_hub import GkeHubAsyncClient +from google.cloud.gkehub_v1.services.gke_hub import GkeHubClient +from google.cloud.gkehub_v1.services.gke_hub import pagers +from google.cloud.gkehub_v1.services.gke_hub import transports +from google.cloud.gkehub_v1.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1.types import feature +from google.cloud.gkehub_v1.types import membership +from google.cloud.gkehub_v1.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert GkeHubClient._get_default_mtls_endpoint(None) is None + assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_service_account_always_use_jwt(client_class): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_file(client_class): + 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") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_client_get_transport_class(): + transport = GkeHubClient.get_transport_class() + available_transports = [ + transports.GkeHubGrpcTransport, + ] + assert transport in available_transports + + transport = GkeHubClient.get_transport_class("grpc") + assert transport == transports.GkeHubGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +def test_gke_hub_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + 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) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_gke_hub_client_client_options_from_dict(): + with mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = GkeHubClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_list_memberships(transport: str = 'grpc', request_type=service.ListMembershipsRequest): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_memberships(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.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_memberships_from_dict(): + test_list_memberships(request_type=dict) + + +def test_list_memberships_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 = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + client.list_memberships() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListMembershipsRequest() + + +@pytest.mark.asyncio +async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=service.ListMembershipsRequest): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_memberships(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_memberships_async_from_dict(): + await test_list_memberships_async(request_type=dict) + + +def test_list_memberships_field_headers(): + client = GkeHubClient( + 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.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = service.ListMembershipsResponse() + client.list_memberships(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_memberships_field_headers_async(): + client = GkeHubAsyncClient( + 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.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse()) + await client.list_memberships(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_memberships_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListMembershipsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_memberships_flattened_error(): + client = GkeHubClient( + 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_memberships( + service.ListMembershipsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListMembershipsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_error_async(): + client = GkeHubAsyncClient( + 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_memberships( + service.ListMembershipsRequest(), + parent='parent_value', + ) + + +def test_list_memberships_pager(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + service.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_memberships(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, membership.Membership) + for i in results) + +def test_list_memberships_pages(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + service.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = list(client.list_memberships(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_memberships_async_pager(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + service.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_memberships(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, membership.Membership) + for i in responses) + +@pytest.mark.asyncio +async def test_list_memberships_async_pages(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + service.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + service.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_memberships(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_features(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.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_features_from_dict(): + test_list_features(request_type=dict) + + +def test_list_features_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 = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + client.list_features() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + +@pytest.mark.asyncio +async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_features(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_features_async_from_dict(): + await test_list_features_async(request_type=dict) + + +def test_list_features_field_headers(): + client = GkeHubClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = service.ListFeaturesResponse() + client.list_features(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_features_field_headers_async(): + client = GkeHubAsyncClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + await client.list_features(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_features_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_features_flattened_error(): + client = GkeHubClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_features_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_features_flattened_error_async(): + client = GkeHubAsyncClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +def test_list_features_pager(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_features(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, feature.Feature) + for i in results) + +def test_list_features_pages(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = list(client.list_features(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_features_async_pager(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_features(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, feature.Feature) + for i in responses) + +@pytest.mark.asyncio +async def test_list_features_async_pages(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_features(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_membership(transport: str = 'grpc', request_type=service.GetMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), + ) + response = client.get_membership(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.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + + +def test_get_membership_from_dict(): + test_get_membership(request_type=dict) + + +def test_get_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.get_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetMembershipRequest() + + +@pytest.mark.asyncio +async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=service.GetMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + )) + response = await client.get_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + + +@pytest.mark.asyncio +async def test_get_membership_async_from_dict(): + await test_get_membership_async(request_type=dict) + + +def test_get_membership_field_headers(): + client = GkeHubClient( + 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.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = membership.Membership() + client.get_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + await client.get_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + service.GetMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + service.GetMembershipRequest(), + name='name_value', + ) + + +def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature( + name='name_value', + ) + response = client.get_feature(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.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +def test_get_feature_from_dict(): + test_get_feature(request_type=dict) + + +def test_get_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.get_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + +@pytest.mark.asyncio +async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( + name='name_value', + )) + response = await client.get_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_async_from_dict(): + await test_get_feature_async(request_type=dict) + + +def test_get_feature_field_headers(): + client = GkeHubClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = feature.Feature() + client.get_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + await client.get_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +def test_create_membership(transport: str = 'grpc', request_type=service.CreateMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_membership(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.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_membership_from_dict(): + test_create_membership(request_type=dict) + + +def test_create_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.create_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateMembershipRequest() + + +@pytest.mark.asyncio +async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=service.CreateMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_membership_async_from_dict(): + await test_create_membership_async(request_type=dict) + + +def test_create_membership_field_headers(): + client = GkeHubClient( + 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.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_membership( + parent='parent_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) + assert args[0].membership_id == 'membership_id_value' + + +def test_create_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + service.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + membership_id='membership_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_membership( + parent='parent_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) + assert args[0].membership_id == 'membership_id_value' + + +@pytest.mark.asyncio +async def test_create_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + service.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + membership_id='membership_id_value', + ) + + +def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_feature(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.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_feature_from_dict(): + test_create_feature(request_type=dict) + + +def test_create_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.create_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + +@pytest.mark.asyncio +async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_feature_async_from_dict(): + await test_create_feature_async(request_type=dict) + + +def test_create_feature_field_headers(): + client = GkeHubClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +def test_create_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +@pytest.mark.asyncio +async def test_create_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +def test_delete_membership(transport: str = 'grpc', request_type=service.DeleteMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_membership(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.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_membership_from_dict(): + test_delete_membership(request_type=dict) + + +def test_delete_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.delete_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteMembershipRequest() + + +@pytest.mark.asyncio +async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=service.DeleteMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_membership_async_from_dict(): + await test_delete_membership_async(request_type=dict) + + +def test_delete_membership_field_headers(): + client = GkeHubClient( + 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.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + service.DeleteMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + service.DeleteMembershipRequest(), + name='name_value', + ) + + +def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_feature(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.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_feature_from_dict(): + test_delete_feature(request_type=dict) + + +def test_delete_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.delete_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + +@pytest.mark.asyncio +async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_feature_async_from_dict(): + await test_delete_feature_async(request_type=dict) + + +def test_delete_feature_field_headers(): + client = GkeHubClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +def test_update_membership(transport: str = 'grpc', request_type=service.UpdateMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_membership(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.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_membership_from_dict(): + test_update_membership(request_type=dict) + + +def test_update_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.update_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateMembershipRequest() + + +@pytest.mark.asyncio +async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=service.UpdateMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_membership_async_from_dict(): + await test_update_membership_async(request_type=dict) + + +def test_update_membership_field_headers(): + client = GkeHubClient( + 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.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_membership(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_update_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_membership(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_update_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_membership( + name='name_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + service.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_membership( + name='name_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + service.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_feature(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.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_feature_from_dict(): + test_update_feature(request_type=dict) + + +def test_update_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.update_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + +@pytest.mark.asyncio +async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_feature_async_from_dict(): + await test_update_feature_async(request_type=dict) + + +def test_update_feature_field_headers(): + client = GkeHubClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_feature(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_update_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_feature(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_update_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_generate_connect_manifest(transport: str = 'grpc', request_type=service.GenerateConnectManifestRequest): + client = GkeHubClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.GenerateConnectManifestResponse( + ) + response = client.generate_connect_manifest(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.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.GenerateConnectManifestResponse) + + +def test_generate_connect_manifest_from_dict(): + test_generate_connect_manifest(request_type=dict) + + +def test_generate_connect_manifest_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 = GkeHubClient( + 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.generate_connect_manifest), + '__call__') as call: + client.generate_connect_manifest() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GenerateConnectManifestRequest() + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=service.GenerateConnectManifestRequest): + client = GkeHubAsyncClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.GenerateConnectManifestResponse( + )) + response = await client.generate_connect_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.GenerateConnectManifestResponse) + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async_from_dict(): + await test_generate_connect_manifest_async(request_type=dict) + + +def test_generate_connect_manifest_field_headers(): + client = GkeHubClient( + 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.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = service.GenerateConnectManifestResponse() + client.generate_connect_manifest(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_generate_connect_manifest_field_headers_async(): + client = GkeHubAsyncClient( + 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.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.GenerateConnectManifestResponse()) + await client.generate_connect_manifest(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_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = GkeHubClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.GkeHubGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, +]) +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() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.GkeHubGrpcTransport, + ) + +def test_gke_hub_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_gke_hub_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_memberships', + 'list_features', + 'get_membership', + 'get_feature', + 'create_membership', + 'create_feature', + 'delete_membership', + 'delete_feature', + 'update_membership', + 'update_feature', + 'generate_connect_manifest', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_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('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): + # 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('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_gke_hub_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_gke_hub_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.GkeHubGrpcTransport, grpc_helpers), + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "gkehub.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="gkehub.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_gke_hub_host_no_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + ) + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_host_with_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + ) + assert client.transport._host == 'gkehub.googleapis.com:8000' + +def test_gke_hub_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_gke_hub_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_gke_hub_grpc_lro_client(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_gke_hub_grpc_lro_async_client(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_feature_path(): + project = "squid" + location = "clam" + feature = "whelk" + expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + actual = GkeHubClient.feature_path(project, location, feature) + assert expected == actual + + +def test_parse_feature_path(): + expected = { + "project": "octopus", + "location": "oyster", + "feature": "nudibranch", + } + path = GkeHubClient.feature_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_feature_path(path) + assert expected == actual + +def test_membership_path(): + project = "cuttlefish" + location = "mussel" + membership = "winkle" + expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + actual = GkeHubClient.membership_path(project, location, membership) + assert expected == actual + + +def test_parse_membership_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "membership": "abalone", + } + path = GkeHubClient.membership_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_membership_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "squid" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = GkeHubClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = GkeHubClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "whelk" + expected = "folders/{folder}".format(folder=folder, ) + actual = GkeHubClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = GkeHubClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "oyster" + expected = "organizations/{organization}".format(organization=organization, ) + actual = GkeHubClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = GkeHubClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "cuttlefish" + expected = "projects/{project}".format(project=project, ) + actual = GkeHubClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = GkeHubClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = GkeHubClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = GkeHubClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + transport_class = GkeHubClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/.coveragerc b/owl-bot-staging/v1alpha/.coveragerc new file mode 100644 index 0000000..deeba63 --- /dev/null +++ b/owl-bot-staging/v1alpha/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/gkehub/servicemesh/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1alpha/MANIFEST.in b/owl-bot-staging/v1alpha/MANIFEST.in new file mode 100644 index 0000000..ae7c3f3 --- /dev/null +++ b/owl-bot-staging/v1alpha/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/gkehub/servicemesh *.py +recursive-include google/cloud/gkehub/servicemesh_v1alpha *.py diff --git a/owl-bot-staging/v1alpha/README.rst b/owl-bot-staging/v1alpha/README.rst new file mode 100644 index 0000000..db8da88 --- /dev/null +++ b/owl-bot-staging/v1alpha/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Gkehub Servicemesh API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Gkehub Servicemesh API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst new file mode 100644 index 0000000..8e59054 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Cloudauditlogging v1alpha API +============================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst new file mode 100644 index 0000000..a8de03d --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Cloudauditlogging v1alpha API +=========================================================== + +.. automodule:: google.cloud.gkehub.cloudauditlogging_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/conf.py b/owl-bot-staging/v1alpha/docs/conf.py new file mode 100644 index 0000000..cd62351 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# +# google-cloud-gkehub-servicemesh documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-gkehub-servicemesh" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Gkehub Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-gkehub-servicemesh-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-gkehub-servicemesh.tex", + u"google-cloud-gkehub-servicemesh Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-gkehub-servicemesh", + u"Google Cloud Gkehub Servicemesh Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-gkehub-servicemesh", + u"google-cloud-gkehub-servicemesh Documentation", + author, + "google-cloud-gkehub-servicemesh", + "GAPIC library for Google Cloud Gkehub Servicemesh API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst new file mode 100644 index 0000000..69a930c --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Configmanagement v1alpha API +============================================================= +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst new file mode 100644 index 0000000..cb8d802 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Configmanagement v1alpha API +========================================================== + +.. automodule:: google.cloud.gkehub.configmanagement_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst new file mode 100644 index 0000000..35f64dd --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst @@ -0,0 +1,10 @@ +GkeHub +------------------------ + +.. automodule:: google.cloud.gkehub_v1alpha.services.gke_hub + :members: + :inherited-members: + +.. automodule:: google.cloud.gkehub_v1alpha.services.gke_hub.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst new file mode 100644 index 0000000..e3e1d71 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Gkehub v1alpha API +============================================ +.. toctree:: + :maxdepth: 2 + + gke_hub diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst new file mode 100644 index 0000000..6f3888d --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub v1alpha API +========================================= + +.. automodule:: google.cloud.gkehub_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/index.rst b/owl-bot-staging/v1alpha/docs/index.rst new file mode 100644 index 0000000..fb0e098 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + servicemesh_v1alpha/services + servicemesh_v1alpha/types diff --git a/owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst new file mode 100644 index 0000000..aaee9de --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Metering v1alpha API +===================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst new file mode 100644 index 0000000..38cbdd9 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Metering v1alpha API +================================================== + +.. automodule:: google.cloud.gkehub.metering_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst new file mode 100644 index 0000000..61a1cb8 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Multiclusteringress v1alpha API +================================================================ +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst new file mode 100644 index 0000000..4ddb168 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Multiclusteringress v1alpha API +============================================================= + +.. automodule:: google.cloud.gkehub.multiclusteringress_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst new file mode 100644 index 0000000..78b9b6d --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Servicemesh v1alpha API +======================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst new file mode 100644 index 0000000..c52d85a --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Servicemesh v1alpha API +===================================================== + +.. automodule:: google.cloud.gkehub.servicemesh_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py new file mode 100644 index 0000000..320d3fa --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub_v1alpha.services.gke_hub.client import GkeHubClient +from google.cloud.gkehub_v1alpha.services.gke_hub.async_client import GkeHubAsyncClient + +from google.cloud.gkehub_v1alpha.types.feature import CommonFeatureSpec +from google.cloud.gkehub_v1alpha.types.feature import CommonFeatureState +from google.cloud.gkehub_v1alpha.types.feature import Feature +from google.cloud.gkehub_v1alpha.types.feature import FeatureResourceState +from google.cloud.gkehub_v1alpha.types.feature import FeatureState +from google.cloud.gkehub_v1alpha.types.feature import MembershipFeatureSpec +from google.cloud.gkehub_v1alpha.types.feature import MembershipFeatureState +from google.cloud.gkehub_v1alpha.types.service import CreateFeatureRequest +from google.cloud.gkehub_v1alpha.types.service import DeleteFeatureRequest +from google.cloud.gkehub_v1alpha.types.service import GetFeatureRequest +from google.cloud.gkehub_v1alpha.types.service import ListFeaturesRequest +from google.cloud.gkehub_v1alpha.types.service import ListFeaturesResponse +from google.cloud.gkehub_v1alpha.types.service import OperationMetadata +from google.cloud.gkehub_v1alpha.types.service import UpdateFeatureRequest + +__all__ = ('GkeHubClient', + 'GkeHubAsyncClient', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'GetFeatureRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'OperationMetadata', + 'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py new file mode 100644 index 0000000..d2889ec --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.cloudauditlogging_v1alpha.types.cloudauditlogging import FeatureSpec + +__all__ = ('FeatureSpec', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed new file mode 100644 index 0000000..1ae262f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-cloudauditlogging package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py new file mode 100644 index 0000000..9d603d2 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.cloudauditlogging import FeatureSpec + +__all__ = ( +'FeatureSpec', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..2967b5d --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.cloudauditlogging_v1alpha", + "protoPackage": "google.cloud.gkehub.cloudauditlogging.v1alpha", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed new file mode 100644 index 0000000..1ae262f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-cloudauditlogging package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py new file mode 100644 index 0000000..d2b5688 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .cloudauditlogging import ( + FeatureSpec, +) + +__all__ = ( + 'FeatureSpec', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py new file mode 100644 index 0000000..5cfd9ce --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.cloudauditlogging.v1alpha', + manifest={ + 'FeatureSpec', + }, +) + + +class FeatureSpec(proto.Message): + r"""**Cloud Audit Logging**: Spec for Audit Logging Allowlisting. + Attributes: + allowlisted_service_accounts (Sequence[str]): + Service account that should be allowlisted to + send the audit logs; eg cloudauditlogging@gcp- + project.iam.gserviceaccount.com. These accounts + must already exist, but do not need to have any + permissions granted to them. The customer's + entitlements will be checked prior to + allowlisting (i.e. the customer must be an + Anthos customer.) + """ + + allowlisted_service_accounts = proto.RepeatedField( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py new file mode 100644 index 0000000..3df965d --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzConfig +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzVersion +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSync +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncDeploymentState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncVersion +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ErrorResource +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GatekeeperDeploymentState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GitConfig +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GroupVersionKind +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerConfig +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerDeploymentState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerVersion +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import InstallError +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import MembershipSpec +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import MembershipState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import OperatorState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyController +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyControllerState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyControllerVersion +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import SyncError +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import SyncState +from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import DeploymentState + +__all__ = ('BinauthzConfig', + 'BinauthzState', + 'BinauthzVersion', + 'ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py new file mode 100644 index 0000000..03dba4e --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.configmanagement import BinauthzConfig +from .types.configmanagement import BinauthzState +from .types.configmanagement import BinauthzVersion +from .types.configmanagement import ConfigSync +from .types.configmanagement import ConfigSyncDeploymentState +from .types.configmanagement import ConfigSyncState +from .types.configmanagement import ConfigSyncVersion +from .types.configmanagement import ErrorResource +from .types.configmanagement import GatekeeperDeploymentState +from .types.configmanagement import GitConfig +from .types.configmanagement import GroupVersionKind +from .types.configmanagement import HierarchyControllerConfig +from .types.configmanagement import HierarchyControllerDeploymentState +from .types.configmanagement import HierarchyControllerState +from .types.configmanagement import HierarchyControllerVersion +from .types.configmanagement import InstallError +from .types.configmanagement import MembershipSpec +from .types.configmanagement import MembershipState +from .types.configmanagement import OperatorState +from .types.configmanagement import PolicyController +from .types.configmanagement import PolicyControllerState +from .types.configmanagement import PolicyControllerVersion +from .types.configmanagement import SyncError +from .types.configmanagement import SyncState +from .types.configmanagement import DeploymentState + +__all__ = ( +'BinauthzConfig', +'BinauthzState', +'BinauthzVersion', +'ConfigSync', +'ConfigSyncDeploymentState', +'ConfigSyncState', +'ConfigSyncVersion', +'DeploymentState', +'ErrorResource', +'GatekeeperDeploymentState', +'GitConfig', +'GroupVersionKind', +'HierarchyControllerConfig', +'HierarchyControllerDeploymentState', +'HierarchyControllerState', +'HierarchyControllerVersion', +'InstallError', +'MembershipSpec', +'MembershipState', +'OperatorState', +'PolicyController', +'PolicyControllerState', +'PolicyControllerVersion', +'SyncError', +'SyncState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..d77aedb --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.configmanagement_v1alpha", + "protoPackage": "google.cloud.gkehub.configmanagement.v1alpha", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py new file mode 100644 index 0000000..91fc337 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .configmanagement import ( + BinauthzConfig, + BinauthzState, + BinauthzVersion, + ConfigSync, + ConfigSyncDeploymentState, + ConfigSyncState, + ConfigSyncVersion, + ErrorResource, + GatekeeperDeploymentState, + GitConfig, + GroupVersionKind, + HierarchyControllerConfig, + HierarchyControllerDeploymentState, + HierarchyControllerState, + HierarchyControllerVersion, + InstallError, + MembershipSpec, + MembershipState, + OperatorState, + PolicyController, + PolicyControllerState, + PolicyControllerVersion, + SyncError, + SyncState, + DeploymentState, +) + +__all__ = ( + 'BinauthzConfig', + 'BinauthzState', + 'BinauthzVersion', + 'ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py new file mode 100644 index 0000000..afc4755 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py @@ -0,0 +1,852 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.configmanagement.v1alpha', + manifest={ + 'DeploymentState', + 'MembershipState', + 'MembershipSpec', + 'ConfigSync', + 'GitConfig', + 'PolicyController', + 'BinauthzConfig', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerVersion', + 'HierarchyControllerState', + 'OperatorState', + 'InstallError', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ConfigSyncDeploymentState', + 'SyncState', + 'SyncError', + 'ErrorResource', + 'GroupVersionKind', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'BinauthzState', + 'BinauthzVersion', + 'GatekeeperDeploymentState', + }, +) + + +class DeploymentState(proto.Enum): + r"""Enum representing the state of an ACM's deployment on a + cluster + """ + DEPLOYMENT_STATE_UNSPECIFIED = 0 + NOT_INSTALLED = 1 + INSTALLED = 2 + ERROR = 3 + + +class MembershipState(proto.Message): + r"""**Anthos Config Management**: State for a single cluster. + Attributes: + cluster_name (str): + The user-defined name for the cluster used by + ClusterSelectors to group clusters together. This should + match Membership's membership_name, unless the user + installed ACM on the cluster manually prior to enabling the + ACM hub feature. Unique within a Anthos Config Management + installation. + membership_spec (google.cloud.gkehub.configmanagement_v1alpha.types.MembershipSpec): + Membership configuration in the cluster. This + represents the actual state in the cluster, + while the MembershipSpec in the FeatureSpec + represents the intended state + operator_state (google.cloud.gkehub.configmanagement_v1alpha.types.OperatorState): + Current install status of ACM's Operator + config_sync_state (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncState): + Current sync status + policy_controller_state (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyControllerState): + PolicyController status + binauthz_state (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzState): + Binauthz status + hierarchy_controller_state (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerState): + Hierarchy Controller status + """ + + cluster_name = proto.Field( + proto.STRING, + number=1, + ) + membership_spec = proto.Field( + proto.MESSAGE, + number=2, + message='MembershipSpec', + ) + operator_state = proto.Field( + proto.MESSAGE, + number=3, + message='OperatorState', + ) + config_sync_state = proto.Field( + proto.MESSAGE, + number=4, + message='ConfigSyncState', + ) + policy_controller_state = proto.Field( + proto.MESSAGE, + number=5, + message='PolicyControllerState', + ) + binauthz_state = proto.Field( + proto.MESSAGE, + number=6, + message='BinauthzState', + ) + hierarchy_controller_state = proto.Field( + proto.MESSAGE, + number=7, + message='HierarchyControllerState', + ) + + +class MembershipSpec(proto.Message): + r"""**Anthos Config Management**: Configuration for a single cluster. + Intended to parallel the ConfigManagement CR. + + Attributes: + config_sync (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSync): + Config Sync configuration for the cluster. + policy_controller (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyController): + Policy Controller configuration for the + cluster. + binauthz (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzConfig): + Binauthz conifguration for the cluster. + hierarchy_controller (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerConfig): + Hierarchy Controller configuration for the + cluster. + version (str): + Version of ACM installed. + """ + + config_sync = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSync', + ) + policy_controller = proto.Field( + proto.MESSAGE, + number=2, + message='PolicyController', + ) + binauthz = proto.Field( + proto.MESSAGE, + number=3, + message='BinauthzConfig', + ) + hierarchy_controller = proto.Field( + proto.MESSAGE, + number=4, + message='HierarchyControllerConfig', + ) + version = proto.Field( + proto.STRING, + number=10, + ) + + +class ConfigSync(proto.Message): + r"""Configuration for Config Sync + Attributes: + git (google.cloud.gkehub.configmanagement_v1alpha.types.GitConfig): + Git repo configuration for the cluster. + source_format (str): + Specifies whether the Config Sync Repo is + in “hierarchical” or “unstructured” mode. + """ + + git = proto.Field( + proto.MESSAGE, + number=7, + message='GitConfig', + ) + source_format = proto.Field( + proto.STRING, + number=8, + ) + + +class GitConfig(proto.Message): + r"""Git repo configuration for a single cluster. + Attributes: + sync_repo (str): + The URL of the Git repository to use as the + source of truth. + sync_branch (str): + The branch of the repository to sync from. + Default: master. + policy_dir (str): + The path within the Git repository that + represents the top level of the repo to sync. + Default: the root directory of the repository. + sync_wait_secs (int): + Period in seconds between consecutive syncs. + Default: 15. + sync_rev (str): + Git revision (tag or hash) to check out. + Default HEAD. + secret_type (str): + Type of secret configured for access to the + Git repo. + https_proxy (str): + URL for the HTTPS proxy to be used when + communicating with the Git repo. + gcp_service_account_email (str): + The GCP Service Account Email used for auth when secret_type + is gcpServiceAccount. + """ + + sync_repo = proto.Field( + proto.STRING, + number=1, + ) + sync_branch = proto.Field( + proto.STRING, + number=2, + ) + policy_dir = proto.Field( + proto.STRING, + number=3, + ) + sync_wait_secs = proto.Field( + proto.INT64, + number=4, + ) + sync_rev = proto.Field( + proto.STRING, + number=5, + ) + secret_type = proto.Field( + proto.STRING, + number=6, + ) + https_proxy = proto.Field( + proto.STRING, + number=7, + ) + gcp_service_account_email = proto.Field( + proto.STRING, + number=8, + ) + + +class PolicyController(proto.Message): + r"""Configuration for Policy Controller + Attributes: + enabled (bool): + Enables the installation of Policy + Controller. If false, the rest of + PolicyController fields take no effect. + template_library_installed (bool): + Installs the default template library along + with Policy Controller. + audit_interval_seconds (int): + Sets the interval for Policy Controller Audit + Scans (in seconds). When set to 0, this disables + audit functionality altogether. + exemptable_namespaces (Sequence[str]): + The set of namespaces that are excluded from + Policy Controller checks. Namespaces do not need + to currently exist on the cluster. + referential_rules_enabled (bool): + Enables the ability to use Constraint + Templates that reference to objects other than + the object currently being evaluated. + log_denies_enabled (bool): + Logs all denies and dry run failures. + mutation_enabled (bool): + Enable users to try out mutation for + PolicyController. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + template_library_installed = proto.Field( + proto.BOOL, + number=2, + optional=True, + ) + audit_interval_seconds = proto.Field( + proto.INT64, + number=3, + optional=True, + ) + exemptable_namespaces = proto.RepeatedField( + proto.STRING, + number=4, + ) + referential_rules_enabled = proto.Field( + proto.BOOL, + number=5, + ) + log_denies_enabled = proto.Field( + proto.BOOL, + number=6, + ) + mutation_enabled = proto.Field( + proto.BOOL, + number=7, + ) + + +class BinauthzConfig(proto.Message): + r"""Configuration for Binauthz + Attributes: + enabled (bool): + Whether binauthz is enabled in this cluster. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + + +class HierarchyControllerConfig(proto.Message): + r"""Configuration for Hierarchy Controller + Attributes: + enabled (bool): + Whether Hierarchy Controller is enabled in + this cluster. + enable_pod_tree_labels (bool): + Whether pod tree labels are enabled in this + cluster. + enable_hierarchical_resource_quota (bool): + Whether hierarchical resource quota is + enabled in this cluster. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + enable_pod_tree_labels = proto.Field( + proto.BOOL, + number=2, + ) + enable_hierarchical_resource_quota = proto.Field( + proto.BOOL, + number=3, + ) + + +class HierarchyControllerDeploymentState(proto.Message): + r"""Deployment state for Hierarchy Controller + Attributes: + hnc (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + The deployment state for open source HNC + (e.g. v0.7.0-hc.0) + extension (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + The deployment state for Hierarchy Controller + extension (e.g. v0.7.0-hc.1) + """ + + hnc = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + extension = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + + +class HierarchyControllerVersion(proto.Message): + r"""Version for Hierarchy Controller + Attributes: + hnc (str): + Version for open source HNC + extension (str): + Version for Hierarchy Controller extension + """ + + hnc = proto.Field( + proto.STRING, + number=1, + ) + extension = proto.Field( + proto.STRING, + number=2, + ) + + +class HierarchyControllerState(proto.Message): + r"""State for Hierarchy Controller + Attributes: + version (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerVersion): + The version for Hierarchy Controller + state (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerDeploymentState): + The deployment state for Hierarchy Controller + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='HierarchyControllerVersion', + ) + state = proto.Field( + proto.MESSAGE, + number=2, + message='HierarchyControllerDeploymentState', + ) + + +class OperatorState(proto.Message): + r"""State information for an ACM's Operator + Attributes: + version (str): + The semenatic version number of the operator + deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + The state of the Operator's deployment + errors (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.InstallError]): + Install errors. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + deployment_state = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='InstallError', + ) + + +class InstallError(proto.Message): + r"""Errors pertaining to the installation of ACM + Attributes: + error_message (str): + A string representing the user facing error + message + """ + + error_message = proto.Field( + proto.STRING, + number=1, + ) + + +class ConfigSyncState(proto.Message): + r"""State information for ConfigSync + Attributes: + version (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncVersion): + The version of ConfigSync deployed + deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncDeploymentState): + Information about the deployment of + ConfigSync, including the version of the various + Pods deployed + sync_state (google.cloud.gkehub.configmanagement_v1alpha.types.SyncState): + The state of ConfigSync's process to sync + configs to a cluster + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSyncVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='ConfigSyncDeploymentState', + ) + sync_state = proto.Field( + proto.MESSAGE, + number=3, + message='SyncState', + ) + + +class ConfigSyncVersion(proto.Message): + r"""Specific versioning information pertaining to ConfigSync's + Pods + + Attributes: + importer (str): + Version of the deployed importer pod + syncer (str): + Version of the deployed syncer pod + git_sync (str): + Version of the deployed git-sync pod + monitor (str): + Version of the deployed monitor pod + reconciler_manager (str): + Version of the deployed reconciler-manager + pod + root_reconciler (str): + Version of the deployed reconciler container + in root-reconciler pod + """ + + importer = proto.Field( + proto.STRING, + number=1, + ) + syncer = proto.Field( + proto.STRING, + number=2, + ) + git_sync = proto.Field( + proto.STRING, + number=3, + ) + monitor = proto.Field( + proto.STRING, + number=4, + ) + reconciler_manager = proto.Field( + proto.STRING, + number=5, + ) + root_reconciler = proto.Field( + proto.STRING, + number=6, + ) + + +class ConfigSyncDeploymentState(proto.Message): + r"""The state of ConfigSync's deployment on a cluster + Attributes: + importer (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of the importer pod + syncer (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of the syncer pod + git_sync (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of the git-sync pod + monitor (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of the monitor pod + reconciler_manager (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of reconciler-manager pod + root_reconciler (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Deployment state of root-reconciler + """ + + importer = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + syncer = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + git_sync = proto.Field( + proto.ENUM, + number=3, + enum='DeploymentState', + ) + monitor = proto.Field( + proto.ENUM, + number=4, + enum='DeploymentState', + ) + reconciler_manager = proto.Field( + proto.ENUM, + number=5, + enum='DeploymentState', + ) + root_reconciler = proto.Field( + proto.ENUM, + number=6, + enum='DeploymentState', + ) + + +class SyncState(proto.Message): + r"""State indicating an ACM's progress syncing configurations to + a cluster + + Attributes: + source_token (str): + Token indicating the state of the repo. + import_token (str): + Token indicating the state of the importer. + sync_token (str): + Token indicating the state of the syncer. + last_sync (str): + Deprecated: use last_sync_time instead. Timestamp of when + ACM last successfully synced the repo The time format is + specified in https://golang.org/pkg/time/#Time.String + last_sync_time (google.protobuf.timestamp_pb2.Timestamp): + Timestamp type of when ACM last successfully + synced the repo + code (google.cloud.gkehub.configmanagement_v1alpha.types.SyncState.SyncCode): + Sync status code + errors (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.SyncError]): + A list of errors resulting from problematic + configs. This list will be truncated after 100 + errors, although it is unlikely for that many + errors to simultaneously exist. + """ + class SyncCode(proto.Enum): + r"""An enum representing an ACM's status syncing configs to a + cluster + """ + SYNC_CODE_UNSPECIFIED = 0 + SYNCED = 1 + PENDING = 2 + ERROR = 3 + NOT_CONFIGURED = 4 + NOT_INSTALLED = 5 + UNAUTHORIZED = 6 + UNREACHABLE = 7 + + source_token = proto.Field( + proto.STRING, + number=1, + ) + import_token = proto.Field( + proto.STRING, + number=2, + ) + sync_token = proto.Field( + proto.STRING, + number=3, + ) + last_sync = proto.Field( + proto.STRING, + number=4, + ) + last_sync_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + code = proto.Field( + proto.ENUM, + number=5, + enum=SyncCode, + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=6, + message='SyncError', + ) + + +class SyncError(proto.Message): + r"""An ACM created error representing a problem syncing + configurations + + Attributes: + code (str): + An ACM defined error code + error_message (str): + A description of the error + error_resources (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.ErrorResource]): + A list of config(s) associated with the + error, if any + """ + + code = proto.Field( + proto.STRING, + number=1, + ) + error_message = proto.Field( + proto.STRING, + number=2, + ) + error_resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ErrorResource', + ) + + +class ErrorResource(proto.Message): + r"""Model for a config file in the git repo with an associated + Sync error + + Attributes: + source_path (str): + Path in the git repo of the erroneous config + resource_name (str): + Metadata name of the resource that is causing + an error + resource_namespace (str): + Namespace of the resource that is causing an + error + resource_gvk (google.cloud.gkehub.configmanagement_v1alpha.types.GroupVersionKind): + Group/version/kind of the resource that is + causing an error + """ + + source_path = proto.Field( + proto.STRING, + number=1, + ) + resource_name = proto.Field( + proto.STRING, + number=2, + ) + resource_namespace = proto.Field( + proto.STRING, + number=3, + ) + resource_gvk = proto.Field( + proto.MESSAGE, + number=4, + message='GroupVersionKind', + ) + + +class GroupVersionKind(proto.Message): + r"""A Kubernetes object's GVK + Attributes: + group (str): + Kubernetes Group + version (str): + Kubernetes Version + kind (str): + Kubernetes Kind + """ + + group = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + kind = proto.Field( + proto.STRING, + number=3, + ) + + +class PolicyControllerState(proto.Message): + r"""State for PolicyControllerState. + Attributes: + version (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyControllerVersion): + The version of Gatekeeper Policy Controller + deployed. + deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.GatekeeperDeploymentState): + The state about the policy controller + installation. + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='PolicyControllerVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='GatekeeperDeploymentState', + ) + + +class PolicyControllerVersion(proto.Message): + r"""The build version of Gatekeeper Policy Controller is using. + Attributes: + version (str): + The gatekeeper image tag that is composed of + ACM version, git tag, build number. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + + +class BinauthzState(proto.Message): + r"""State for Binauthz + Attributes: + webhook (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + The state of the binauthz webhook. + version (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzVersion): + The version of binauthz that is installed. + """ + + webhook = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + version = proto.Field( + proto.MESSAGE, + number=2, + message='BinauthzVersion', + ) + + +class BinauthzVersion(proto.Message): + r"""The version of binauthz. + Attributes: + webhook_version (str): + The version of the binauthz webhook. + """ + + webhook_version = proto.Field( + proto.STRING, + number=1, + ) + + +class GatekeeperDeploymentState(proto.Message): + r"""State of Policy Controller installation. + Attributes: + gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Status of gatekeeper-controller-manager pod. + gatekeeper_audit (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Status of gatekeeper-audit deployment. + gatekeeper_mutation (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): + Status of the pod serving the mutation + webhook. + """ + + gatekeeper_controller_manager_state = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + gatekeeper_audit = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + gatekeeper_mutation = proto.Field( + proto.ENUM, + number=3, + enum='DeploymentState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py new file mode 100644 index 0000000..d22f218 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.metering_v1alpha.types.metering import MembershipState + +__all__ = ('MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed new file mode 100644 index 0000000..1947b3f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-metering package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py new file mode 100644 index 0000000..fe15d24 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.metering import MembershipState + +__all__ = ( +'MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..8eb202d --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.metering_v1alpha", + "protoPackage": "google.cloud.gkehub.metering.v1alpha", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed new file mode 100644 index 0000000..1947b3f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-metering package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py new file mode 100644 index 0000000..9a626f7 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .metering import ( + MembershipState, +) + +__all__ = ( + 'MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py new file mode 100644 index 0000000..ad80813 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.metering.v1alpha', + manifest={ + 'MembershipState', + }, +) + + +class MembershipState(proto.Message): + r"""**Metering**: Per-Membership Feature State. + Attributes: + last_measurement_time (google.protobuf.timestamp_pb2.Timestamp): + The time stamp of the most recent measurement + of the number of vCPUs in the cluster. + precise_last_measured_cluster_vcpu_capacity (float): + The vCPUs capacity in the cluster according + to the most recent measurement (1/1000 + precision). + """ + + last_measurement_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + precise_last_measured_cluster_vcpu_capacity = proto.Field( + proto.FLOAT, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py new file mode 100644 index 0000000..6881b60 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.multiclusteringress_v1alpha.types.multiclusteringress import FeatureSpec +from google.cloud.gkehub.multiclusteringress_v1alpha.types.multiclusteringress import Billing + +__all__ = ('FeatureSpec', + 'Billing', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py new file mode 100644 index 0000000..a8fd7c2 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.multiclusteringress import FeatureSpec +from .types.multiclusteringress import Billing + +__all__ = ( +'Billing', +'FeatureSpec', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..9965b21 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.multiclusteringress_v1alpha", + "protoPackage": "google.cloud.gkehub.multiclusteringress.v1alpha", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py new file mode 100644 index 0000000..28b5fac --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .multiclusteringress import ( + FeatureSpec, + Billing, +) + +__all__ = ( + 'FeatureSpec', + 'Billing', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py new file mode 100644 index 0000000..5a73c5e --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.multiclusteringress.v1alpha', + manifest={ + 'Billing', + 'FeatureSpec', + }, +) + + +class Billing(proto.Enum): + r"""Billing identifies which billing structure the customer is + using. + """ + BILLING_UNSPECIFIED = 0 + PAY_AS_YOU_GO = 1 + ANTHOS_LICENSE = 2 + + +class FeatureSpec(proto.Message): + r"""**Multi-cluster Ingress**: The configuration for the + MultiClusterIngress feature. + + Attributes: + config_membership (str): + Fully-qualified Membership name which hosts the + MultiClusterIngress CRD. Example: + ``projects/foo-proj/locations/global/memberships/bar`` + billing (google.cloud.gkehub.multiclusteringress_v1alpha.types.Billing): + Customer's billing structure + """ + + config_membership = proto.Field( + proto.STRING, + number=1, + ) + billing = proto.Field( + proto.ENUM, + number=2, + enum='Billing', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py new file mode 100644 index 0000000..e3c0a79 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import AnalysisMessage +from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import AnalysisMessageBase +from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import FeatureState +from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import MembershipState + +__all__ = ('AnalysisMessage', + 'AnalysisMessageBase', + 'FeatureState', + 'MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed new file mode 100644 index 0000000..b5ad0fd --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-servicemesh package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py new file mode 100644 index 0000000..92dad68 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.servicemesh import AnalysisMessage +from .types.servicemesh import AnalysisMessageBase +from .types.servicemesh import FeatureState +from .types.servicemesh import MembershipState + +__all__ = ( +'AnalysisMessage', +'AnalysisMessageBase', +'FeatureState', +'MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..3bf3339 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.servicemesh_v1alpha", + "protoPackage": "google.cloud.gkehub.servicemesh.v1alpha", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed new file mode 100644 index 0000000..b5ad0fd --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-servicemesh package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py new file mode 100644 index 0000000..b3b75a3 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .servicemesh import ( + AnalysisMessage, + AnalysisMessageBase, + FeatureState, + MembershipState, +) + +__all__ = ( + 'AnalysisMessage', + 'AnalysisMessageBase', + 'FeatureState', + 'MembershipState', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py new file mode 100644 index 0000000..c524b4c --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import struct_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.servicemesh.v1alpha', + manifest={ + 'FeatureState', + 'MembershipState', + 'AnalysisMessageBase', + 'AnalysisMessage', + }, +) + + +class FeatureState(proto.Message): + r"""**Service Mesh**: State for the whole Hub, as analyzed by the + Service Mesh Hub Controller. + + Attributes: + analysis_messages (Sequence[google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessage]): + Output only. Results of running Service Mesh + analyzers. + """ + + analysis_messages = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='AnalysisMessage', + ) + + +class MembershipState(proto.Message): + r"""**Service Mesh**: State for a single Membership, as analyzed by the + Service Mesh Hub Controller. + + Attributes: + analysis_messages (Sequence[google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessage]): + Output only. Results of running Service Mesh + analyzers. + """ + + analysis_messages = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='AnalysisMessage', + ) + + +class AnalysisMessageBase(proto.Message): + r"""AnalysisMessageBase describes some common information that is + needed for all messages. + + Attributes: + type_ (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase.Type): + Represents the specific type of a message. + level (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase.Level): + Represents how severe a message is. + documentation_url (str): + A url pointing to the Service Mesh or Istio + documentation for this specific error type. + """ + class Level(proto.Enum): + r"""The values here are chosen so that more severe messages get + sorted higher, as well as leaving space in between to add more + later See istio.analysis.v1alpha1.AnalysisMessageBase.Level + """ + LEVEL_UNSPECIFIED = 0 + ERROR = 3 + WARNING = 8 + INFO = 12 + + class Type(proto.Message): + r"""A unique identifier for the type of message. Display_name is + intended to be human-readable, code is intended to be machine + readable. There should be a one-to-one mapping between display_name + and code. (i.e. do not re-use display_names or codes between message + types.) See istio.analysis.v1alpha1.AnalysisMessageBase.Type + + Attributes: + display_name (str): + A human-readable name for the message type. e.g. + "InternalError", "PodMissingProxy". This should be the same + for all messages of the same type. (This corresponds to the + ``name`` field in open-source Istio.) + code (str): + A 7 character code matching ``^IST[0-9]{4}$`` or + ``^ASM[0-9]{4}$``, intended to uniquely identify the message + type. (e.g. "IST0001" is mapped to the "InternalError" + message type.) + """ + + display_name = proto.Field( + proto.STRING, + number=1, + ) + code = proto.Field( + proto.STRING, + number=2, + ) + + type_ = proto.Field( + proto.MESSAGE, + number=1, + message=Type, + ) + level = proto.Field( + proto.ENUM, + number=2, + enum=Level, + ) + documentation_url = proto.Field( + proto.STRING, + number=3, + ) + + +class AnalysisMessage(proto.Message): + r"""AnalysisMessage is a single message produced by an analyzer, + and it used to communicate to the end user about the state of + their Service Mesh configuration. + + Attributes: + message_base (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase): + Details common to all types of Istio and + ServiceMesh analysis messages. + description (str): + A human readable description of what the + error means. It is suitable for non- + internationalize display purposes. + resource_paths (Sequence[str]): + A list of strings specifying the resource identifiers that + were the cause of message generation. A "path" here may be: + + - MEMBERSHIP_ID if the cause is a specific member cluster + - MEMBERSHIP_ID/(NAMESPACE/)?RESOURCETYPE/NAME if the cause + is a resource in a cluster + args (google.protobuf.struct_pb2.Struct): + A UI can combine these args with a template (based on + message_base.type) to produce an internationalized message. + """ + + message_base = proto.Field( + proto.MESSAGE, + number=1, + message='AnalysisMessageBase', + ) + description = proto.Field( + proto.STRING, + number=2, + ) + resource_paths = proto.RepeatedField( + proto.STRING, + number=3, + ) + args = proto.Field( + proto.MESSAGE, + number=4, + message=struct_pb2.Struct, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py new file mode 100644 index 0000000..fe33a01 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .services.gke_hub import GkeHubClient +from .services.gke_hub import GkeHubAsyncClient + +from .types.feature import CommonFeatureSpec +from .types.feature import CommonFeatureState +from .types.feature import Feature +from .types.feature import FeatureResourceState +from .types.feature import FeatureState +from .types.feature import MembershipFeatureSpec +from .types.feature import MembershipFeatureState +from .types.service import CreateFeatureRequest +from .types.service import DeleteFeatureRequest +from .types.service import GetFeatureRequest +from .types.service import ListFeaturesRequest +from .types.service import ListFeaturesResponse +from .types.service import OperationMetadata +from .types.service import UpdateFeatureRequest + +__all__ = ( + 'GkeHubAsyncClient', +'CommonFeatureSpec', +'CommonFeatureState', +'CreateFeatureRequest', +'DeleteFeatureRequest', +'Feature', +'FeatureResourceState', +'FeatureState', +'GetFeatureRequest', +'GkeHubClient', +'ListFeaturesRequest', +'ListFeaturesResponse', +'MembershipFeatureSpec', +'MembershipFeatureState', +'OperationMetadata', +'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json new file mode 100644 index 0000000..eb66ac6 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json @@ -0,0 +1,73 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub_v1alpha", + "protoPackage": "google.cloud.gkehub.v1alpha", + "schema": "1.0", + "services": { + "GkeHub": { + "clients": { + "grpc": { + "libraryClient": "GkeHubClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + } + } + }, + "grpc-async": { + "libraryClient": "GkeHubAsyncClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py new file mode 100644 index 0000000..7304648 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .client import GkeHubClient +from .async_client import GkeHubAsyncClient + +__all__ = ( + 'GkeHubClient', + 'GkeHubAsyncClient', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py new file mode 100644 index 0000000..e5ef4fe --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py @@ -0,0 +1,657 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1alpha.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport +from .client import GkeHubClient + + +class GkeHubAsyncClient: + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1alpha.Membership] + - [Feature][google.cloud.gkehub.v1alpha.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + _client: GkeHubClient + + DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT + + feature_path = staticmethod(GkeHubClient.feature_path) + parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) + common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + common_folder_path = staticmethod(GkeHubClient.common_folder_path) + parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) + common_organization_path = staticmethod(GkeHubClient.common_organization_path) + parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + common_project_path = staticmethod(GkeHubClient.common_project_path) + parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) + common_location_path = staticmethod(GkeHubClient.common_location_path) + parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = GkeHubClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: + r"""Lists Features in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1alpha.types.ListFeaturesRequest`): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (:class:`str`): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1alpha.services.gke_hub.pagers.ListFeaturesAsyncPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest(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_features, + 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.ListFeaturesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (:class:`google.cloud.gkehub_v1alpha.types.GetFeatureRequest`): + The request object. Request message for + `GkeHub.GetFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1alpha.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetFeatureRequest(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_feature, + 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 create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds a new Feature. + + Args: + request (:class:`google.cloud.gkehub_v1alpha.types.CreateFeatureRequest`): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (:class:`str`): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1alpha.types.Feature`): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (:class:`str`): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Feature. + + Args: + request (:class:`google.cloud.gkehub_v1alpha.types.DeleteFeatureRequest`): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteFeatureRequest(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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Feature. + + Args: + request (:class:`google.cloud.gkehub_v1alpha.types.UpdateFeatureRequest`): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1alpha.types.Feature`): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Mask of fields to update. + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubAsyncClient", +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py new file mode 100644 index 0000000..f90e0a2 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py @@ -0,0 +1,844 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1alpha.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import GkeHubGrpcTransport +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +class GkeHubClientMeta(type): + """Metaclass for the GkeHub client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] + _transport_registry["grpc"] = GkeHubGrpcTransport + _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[GkeHubTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class GkeHubClient(metaclass=GkeHubClientMeta): + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1alpha.Membership] + - [Feature][google.cloud.gkehub.v1alpha.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "gkehub.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def feature_path(project: str,location: str,feature: str,) -> str: + """Returns a fully-qualified feature string.""" + return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + + @staticmethod + def parse_feature_path(path: str) -> Dict[str,str]: + """Parses a feature path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?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, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + 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, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, GkeHubTransport): + # transport is a GkeHubTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: + r"""Lists Features in a given project and location. + + Args: + request (google.cloud.gkehub_v1alpha.types.ListFeaturesRequest): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (str): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1alpha.services.gke_hub.pagers.ListFeaturesPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListFeaturesRequest): + request = service.ListFeaturesRequest(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_features] + + # 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.ListFeaturesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (google.cloud.gkehub_v1alpha.types.GetFeatureRequest): + The request object. Request message for + `GkeHub.GetFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1alpha.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetFeatureRequest): + request = service.GetFeatureRequest(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_feature] + + # 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 create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds a new Feature. + + Args: + request (google.cloud.gkehub_v1alpha.types.CreateFeatureRequest): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (str): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1alpha.types.Feature): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (str): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateFeatureRequest): + request = service.CreateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_feature] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Feature. + + Args: + request (google.cloud.gkehub_v1alpha.types.DeleteFeatureRequest): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteFeatureRequest): + request = service.DeleteFeatureRequest(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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Feature. + + Args: + request (google.cloud.gkehub_v1alpha.types.UpdateFeatureRequest): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1alpha.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateFeatureRequest): + request = service.UpdateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubClient", +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py new file mode 100644 index 0000000..71573d9 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service + + +class ListFeaturesPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` + 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.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1alpha.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1alpha.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListFeaturesResponse]: + 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) -> Iterable[feature.Feature]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFeaturesAsyncPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` + 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.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1alpha.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1alpha.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListFeaturesResponse]: + 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) -> AsyncIterable[feature.Feature]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py new file mode 100644 index 0000000..29c1c45 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import GkeHubTransport +from .grpc import GkeHubGrpcTransport +from .grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] +_transport_registry['grpc'] = GkeHubGrpcTransport +_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport + +__all__ = ( + 'GkeHubTransport', + 'GkeHubGrpcTransport', + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py new file mode 100644 index 0000000..00e3c20 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py @@ -0,0 +1,232 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-gke-hub', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class GkeHubTransport(abc.ABC): + """Abstract transport class for GkeHub.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'gkehub.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + 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' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_features: gapic_v1.method.wrap_method( + self.list_features, + default_timeout=None, + client_info=client_info, + ), + self.get_feature: gapic_v1.method.wrap_method( + self.get_feature, + default_timeout=None, + client_info=client_info, + ), + self.create_feature: gapic_v1.method.wrap_method( + self.create_feature, + default_timeout=None, + client_info=client_info, + ), + self.delete_feature: gapic_v1.method.wrap_method( + self.delete_feature, + default_timeout=None, + client_info=client_info, + ), + self.update_feature: gapic_v1.method.wrap_method( + self.update_feature, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Union[ + service.ListFeaturesResponse, + Awaitable[service.ListFeaturesResponse] + ]]: + raise NotImplementedError() + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Union[ + feature.Feature, + Awaitable[feature.Feature] + ]]: + raise NotImplementedError() + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'GkeHubTransport', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py new file mode 100644 index 0000000..546f6be --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py @@ -0,0 +1,386 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO + + +class GkeHubGrpcTransport(GkeHubTransport): + """gRPC backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1alpha.Membership] + - [Feature][google.cloud.gkehub.v1alpha.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + service.ListFeaturesResponse]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + ~.ListFeaturesResponse]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + feature.Feature]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + ~.Feature]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + +__all__ = ( + 'GkeHubGrpcTransport', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py new file mode 100644 index 0000000..91c5359 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py @@ -0,0 +1,390 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .grpc import GkeHubGrpcTransport + + +class GkeHubGrpcAsyncIOTransport(GkeHubTransport): + """gRPC AsyncIO backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1alpha.Membership] + - [Feature][google.cloud.gkehub.v1alpha.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Awaitable[service.ListFeaturesResponse]]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + Awaitable[~.ListFeaturesResponse]]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Awaitable[feature.Feature]]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + Awaitable[~.Feature]]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + +__all__ = ( + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py new file mode 100644 index 0000000..09483e1 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .feature import ( + CommonFeatureSpec, + CommonFeatureState, + Feature, + FeatureResourceState, + FeatureState, + MembershipFeatureSpec, + MembershipFeatureState, +) +from .service import ( + CreateFeatureRequest, + DeleteFeatureRequest, + GetFeatureRequest, + ListFeaturesRequest, + ListFeaturesResponse, + OperationMetadata, + UpdateFeatureRequest, +) + +__all__ = ( + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'GetFeatureRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'OperationMetadata', + 'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py new file mode 100644 index 0000000..a751f2f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py @@ -0,0 +1,329 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub.cloudauditlogging.v1alpha import cloudauditlogging_pb2 # type: ignore +from google.cloud.gkehub.configmanagement.v1alpha import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.metering.v1alpha import metering_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1alpha import multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub.servicemesh.v1alpha import servicemesh_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1alpha', + manifest={ + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + }, +) + + +class Feature(proto.Message): + r"""Feature represents the settings and status of any Hub + Feature. + + Attributes: + name (str): + Output only. The full, unique name of this Feature resource + in the format ``projects/*/locations/*/features/*``. + labels (Sequence[google.cloud.gkehub_v1alpha.types.Feature.LabelsEntry]): + GCP labels for this Feature. + resource_state (google.cloud.gkehub_v1alpha.types.FeatureResourceState): + Output only. State of the Feature resource + itself. + spec (google.cloud.gkehub_v1alpha.types.CommonFeatureSpec): + Optional. Hub-wide Feature configuration. If + this Feature does not support any Hub-wide + configuration, this field may be unused. + membership_specs (Sequence[google.cloud.gkehub_v1alpha.types.Feature.MembershipSpecsEntry]): + Optional. Membership-specific configuration + for this Feature. If this Feature does not + support any per-Membership configuration, this + field may be unused. + The keys indicate which Membership the + configuration is for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} WILL match the + Feature's project. + + {p} will always be returned as the project + number, but the project ID is also accepted + during input. If the same Membership is + specified in the map twice (using the project ID + form, and the project number form), exactly ONE + of the entries will be saved, with no guarantees + as to which. For this reason, it is recommended + the same format be used for all entries when + mutating a Feature. + state (google.cloud.gkehub_v1alpha.types.CommonFeatureState): + Output only. The Hub-wide Feature state. + membership_states (Sequence[google.cloud.gkehub_v1alpha.types.Feature.MembershipStatesEntry]): + Output only. Membership-specific Feature + status. If this Feature does report any per- + Membership status, this field may be unused. + The keys indicate which Membership the state is + for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project number, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} MUST match the + Feature's project number. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + last updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + deleted. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + resource_state = proto.Field( + proto.MESSAGE, + number=3, + message='FeatureResourceState', + ) + spec = proto.Field( + proto.MESSAGE, + number=4, + message='CommonFeatureSpec', + ) + membership_specs = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=5, + message='MembershipFeatureSpec', + ) + state = proto.Field( + proto.MESSAGE, + number=6, + message='CommonFeatureState', + ) + membership_states = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=7, + message='MembershipFeatureState', + ) + create_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, + ) + + +class FeatureResourceState(proto.Message): + r"""FeatureResourceState describes the state of a Feature *resource* in + the GkeHub API. See ``FeatureState`` for the "running state" of the + Feature in the Hub and across Memberships. + + Attributes: + state (google.cloud.gkehub_v1alpha.types.FeatureResourceState.State): + The current state of the Feature resource in + the Hub API. + """ + class State(proto.Enum): + r"""State describes the lifecycle status of a Feature.""" + STATE_UNSPECIFIED = 0 + ENABLING = 1 + ACTIVE = 2 + DISABLING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + + +class FeatureState(proto.Message): + r"""FeatureState describes the high-level state of a Feature. It + may be used to describe a Feature's state at the environ-level, + or per-membershop, depending on the context. + + Attributes: + code (google.cloud.gkehub_v1alpha.types.FeatureState.Code): + The high-level, machine-readable status of + this Feature. + description (str): + A human-readable description of the current + status. + update_time (google.protobuf.timestamp_pb2.Timestamp): + The time this status and any related Feature- + pecific details were updated. + """ + class Code(proto.Enum): + r"""Code represents a machine-readable, high-level status of the + Feature. + """ + CODE_UNSPECIFIED = 0 + OK = 1 + WARNING = 2 + ERROR = 3 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + + +class CommonFeatureSpec(proto.Message): + r"""CommonFeatureSpec contains Hub-wide configuration information + Attributes: + multiclusteringress (google.cloud.gkehub.multiclusteringress.v1alpha.multiclusteringress_pb2.FeatureSpec): + Multicluster Ingress-specific spec. + cloudauditlogging (google.cloud.gkehub.cloudauditlogging.v1alpha.cloudauditlogging_pb2.FeatureSpec): + Cloud Audit Logging-specific spec. + """ + + multiclusteringress = proto.Field( + proto.MESSAGE, + number=102, + oneof='feature_spec', + message=multiclusteringress_pb2.FeatureSpec, + ) + cloudauditlogging = proto.Field( + proto.MESSAGE, + number=108, + oneof='feature_spec', + message=cloudauditlogging_pb2.FeatureSpec, + ) + + +class CommonFeatureState(proto.Message): + r"""CommonFeatureState contains Hub-wide Feature status + information. + + Attributes: + servicemesh (google.cloud.gkehub.servicemesh.v1alpha.servicemesh_pb2.FeatureState): + Service Mesh-specific state. + state (google.cloud.gkehub_v1alpha.types.FeatureState): + Output only. The "running state" of the + Feature in this Hub. + """ + + servicemesh = proto.Field( + proto.MESSAGE, + number=100, + oneof='feature_state', + message=servicemesh_pb2.FeatureState, + ) + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +class MembershipFeatureSpec(proto.Message): + r"""MembershipFeatureSpec contains configuration information for + a single Membership. + + Attributes: + configmanagement (google.cloud.gkehub.configmanagement.v1alpha.configmanagement_pb2.MembershipSpec): + Config Management-specific spec. + """ + + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_spec', + message=configmanagement_pb2.MembershipSpec, + ) + + +class MembershipFeatureState(proto.Message): + r"""MembershipFeatureState contains Feature status information + for a single Membership. + + Attributes: + servicemesh (google.cloud.gkehub.servicemesh.v1alpha.servicemesh_pb2.MembershipState): + Service Mesh-specific state. + metering (google.cloud.gkehub.metering.v1alpha.metering_pb2.MembershipState): + Metering-specific spec. + configmanagement (google.cloud.gkehub.configmanagement.v1alpha.configmanagement_pb2.MembershipState): + Config Management-specific state. + state (google.cloud.gkehub_v1alpha.types.FeatureState): + The high-level state of this Feature for a + single membership. + """ + + servicemesh = proto.Field( + proto.MESSAGE, + number=100, + oneof='feature_state', + message=servicemesh_pb2.MembershipState, + ) + metering = proto.Field( + proto.MESSAGE, + number=104, + oneof='feature_state', + message=metering_pb2.MembershipState, + ) + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_state', + message=configmanagement_pb2.MembershipState, + ) + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py new file mode 100644 index 0000000..179ce0c --- /dev/null +++ b/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py @@ -0,0 +1,351 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub_v1alpha.types import feature +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1alpha', + manifest={ + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'GetFeatureRequest', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'UpdateFeatureRequest', + 'OperationMetadata', + }, +) + + +class ListFeaturesRequest(proto.Message): + r"""Request message for ``GkeHub.ListFeatures`` method. + Attributes: + parent (str): + The parent (project and location) where the Features will be + listed. Specified in the format ``projects/*/locations/*``. + page_size (int): + When requesting a 'page' of resources, ``page_size`` + specifies number of resources to return. If unspecified or + set to 0, all resources will be returned. + page_token (str): + Token returned by previous call to ``ListFeatures`` which + specifies the position in the list from where to continue + listing the resources. + filter (str): + Lists Features that match the filter expression, following + the syntax outlined in https://google.aip.dev/160. + + Examples: + + - Feature with the name "servicemesh" in project + "foo-proj": + + name = + "projects/foo-proj/locations/global/features/servicemesh" + + - Features that have a label called ``foo``: + + labels.foo:\* + + - Features that have a label called ``foo`` whose value is + ``bar``: + + labels.foo = bar + order_by (str): + One or more fields to compare and use to sort + the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListFeaturesResponse(proto.Message): + r"""Response message for the ``GkeHub.ListFeatures`` method. + Attributes: + resources (Sequence[google.cloud.gkehub_v1alpha.types.Feature]): + The list of matching Features + next_page_token (str): + A token to request the next page of resources from the + ``ListFeatures`` method. The value of an empty string means + that there are no more resources to return. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=feature.Feature, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.GetFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateFeatureRequest(proto.Message): + r"""Request message for the ``GkeHub.CreateFeature`` method. + Attributes: + parent (str): + The parent (project and location) where the Feature will be + created. Specified in the format ``projects/*/locations/*``. + feature_id (str): + The ID of the feature to create. + resource (google.cloud.gkehub_v1alpha.types.Feature): + The Feature resource to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + feature_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DeleteFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.DeleteFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + force (bool): + If set to true, the delete will ignore any outstanding + resources for this Feature (that is, + ``FeatureState.has_resources`` is set to true). These + resources will NOT be cleaned up or modified in any way. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + force = proto.Field( + proto.BOOL, + number=2, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.UpdateFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + resource (google.cloud.gkehub_v1alpha.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are updating a + map field, set the value of a key to null or empty string to + delete the key from the map. It's not possible to update a + key's value to the empty string. If you specify the + update_mask to be a special path "*", fully replaces all + user-modifiable fields to match ``resource``. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_detail (str): + Output only. Human-readable status of the + operation, if any. + cancel_requested (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/mypy.ini b/owl-bot-staging/v1alpha/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1alpha/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1alpha/noxfile.py b/owl-bot-staging/v1alpha/noxfile.py new file mode 100644 index 0000000..17622d4 --- /dev/null +++ b/owl-bot-staging/v1alpha/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/gkehub/servicemesh_v1alpha/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py new file mode 100644 index 0000000..5b4c228 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class cloudauditloggingCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=cloudauditloggingCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the cloudauditlogging client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py new file mode 100644 index 0000000..b06f1d0 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class configmanagementCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=configmanagementCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the configmanagement client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py new file mode 100644 index 0000000..fadc530 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py @@ -0,0 +1,180 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class gkehubCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_feature': ('parent', 'feature_id', 'resource', 'request_id', ), + 'delete_feature': ('name', 'force', 'request_id', ), + 'get_feature': ('name', ), + 'list_features': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_feature': ('name', 'update_mask', 'resource', 'request_id', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=gkehubCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the gkehub client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py new file mode 100644 index 0000000..53d00e3 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class meteringCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=meteringCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the metering client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py new file mode 100644 index 0000000..e15ebbc --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class multiclusteringressCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=multiclusteringressCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the multiclusteringress client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py new file mode 100644 index 0000000..90afc52 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class servicemeshCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=servicemeshCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the servicemesh client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha/setup.py b/owl-bot-staging/v1alpha/setup.py new file mode 100644 index 0000000..f9b3488 --- /dev/null +++ b/owl-bot-staging/v1alpha/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-gkehub-servicemesh', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1alpha/tests/__init__.py b/owl-bot-staging/v1alpha/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/__init__.py b/owl-bot-staging/v1alpha/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py b/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py new file mode 100644 index 0000000..41c5ee1 --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py @@ -0,0 +1,2336 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +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 operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.gkehub.cloudauditlogging.v1alpha import cloudauditlogging_pb2 # type: ignore +from google.cloud.gkehub.configmanagement.v1alpha import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.metering.v1alpha import metering_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1alpha import multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub.servicemesh.v1alpha import servicemesh_pb2 # type: ignore +from google.cloud.gkehub_v1alpha.services.gke_hub import GkeHubAsyncClient +from google.cloud.gkehub_v1alpha.services.gke_hub import GkeHubClient +from google.cloud.gkehub_v1alpha.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha.services.gke_hub import transports +from google.cloud.gkehub_v1alpha.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1alpha.types import feature +from google.cloud.gkehub_v1alpha.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert GkeHubClient._get_default_mtls_endpoint(None) is None + assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_service_account_always_use_jwt(client_class): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_file(client_class): + 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") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_client_get_transport_class(): + transport = GkeHubClient.get_transport_class() + available_transports = [ + transports.GkeHubGrpcTransport, + ] + assert transport in available_transports + + transport = GkeHubClient.get_transport_class("grpc") + assert transport == transports.GkeHubGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +def test_gke_hub_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + 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) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_gke_hub_client_client_options_from_dict(): + with mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = GkeHubClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_features(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.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_features_from_dict(): + test_list_features(request_type=dict) + + +def test_list_features_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 = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + client.list_features() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + +@pytest.mark.asyncio +async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_features(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_features_async_from_dict(): + await test_list_features_async(request_type=dict) + + +def test_list_features_field_headers(): + client = GkeHubClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = service.ListFeaturesResponse() + client.list_features(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_features_field_headers_async(): + client = GkeHubAsyncClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + await client.list_features(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_features_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_features_flattened_error(): + client = GkeHubClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_features_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_features_flattened_error_async(): + client = GkeHubAsyncClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +def test_list_features_pager(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_features(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, feature.Feature) + for i in results) + +def test_list_features_pages(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = list(client.list_features(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_features_async_pager(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_features(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, feature.Feature) + for i in responses) + +@pytest.mark.asyncio +async def test_list_features_async_pages(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_features(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature( + name='name_value', + ) + response = client.get_feature(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.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +def test_get_feature_from_dict(): + test_get_feature(request_type=dict) + + +def test_get_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.get_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + +@pytest.mark.asyncio +async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( + name='name_value', + )) + response = await client.get_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_async_from_dict(): + await test_get_feature_async(request_type=dict) + + +def test_get_feature_field_headers(): + client = GkeHubClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = feature.Feature() + client.get_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + await client.get_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_feature(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.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_feature_from_dict(): + test_create_feature(request_type=dict) + + +def test_create_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.create_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + +@pytest.mark.asyncio +async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_feature_async_from_dict(): + await test_create_feature_async(request_type=dict) + + +def test_create_feature_field_headers(): + client = GkeHubClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +def test_create_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +@pytest.mark.asyncio +async def test_create_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_feature(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.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_feature_from_dict(): + test_delete_feature(request_type=dict) + + +def test_delete_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.delete_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + +@pytest.mark.asyncio +async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_feature_async_from_dict(): + await test_delete_feature_async(request_type=dict) + + +def test_delete_feature_field_headers(): + client = GkeHubClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_feature(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.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_feature_from_dict(): + test_update_feature(request_type=dict) + + +def test_update_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.update_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + +@pytest.mark.asyncio +async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_feature_async_from_dict(): + await test_update_feature_async(request_type=dict) + + +def test_update_feature_field_headers(): + client = GkeHubClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_feature(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_update_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_feature(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_update_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(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.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = GkeHubClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.GkeHubGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, +]) +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() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.GkeHubGrpcTransport, + ) + +def test_gke_hub_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_gke_hub_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_features', + 'get_feature', + 'create_feature', + 'delete_feature', + 'update_feature', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_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('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): + # 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('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_gke_hub_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_gke_hub_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.GkeHubGrpcTransport, grpc_helpers), + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "gkehub.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="gkehub.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_gke_hub_host_no_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + ) + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_host_with_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + ) + assert client.transport._host == 'gkehub.googleapis.com:8000' + +def test_gke_hub_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_gke_hub_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_gke_hub_grpc_lro_client(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_gke_hub_grpc_lro_async_client(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_feature_path(): + project = "squid" + location = "clam" + feature = "whelk" + expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + actual = GkeHubClient.feature_path(project, location, feature) + assert expected == actual + + +def test_parse_feature_path(): + expected = { + "project": "octopus", + "location": "oyster", + "feature": "nudibranch", + } + path = GkeHubClient.feature_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_feature_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = GkeHubClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = GkeHubClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = GkeHubClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = GkeHubClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = GkeHubClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = GkeHubClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = GkeHubClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = GkeHubClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = GkeHubClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = GkeHubClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + transport_class = GkeHubClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/.coveragerc b/owl-bot-staging/v1alpha2/.coveragerc new file mode 100644 index 0000000..2b3ad0f --- /dev/null +++ b/owl-bot-staging/v1alpha2/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/gkehub/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1alpha2/MANIFEST.in b/owl-bot-staging/v1alpha2/MANIFEST.in new file mode 100644 index 0000000..794cce1 --- /dev/null +++ b/owl-bot-staging/v1alpha2/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/gkehub *.py +recursive-include google/cloud/gkehub_v1alpha2 *.py diff --git a/owl-bot-staging/v1alpha2/README.rst b/owl-bot-staging/v1alpha2/README.rst new file mode 100644 index 0000000..00b883a --- /dev/null +++ b/owl-bot-staging/v1alpha2/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Gkehub API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Gkehub API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1alpha2/docs/conf.py b/owl-bot-staging/v1alpha2/docs/conf.py new file mode 100644 index 0000000..2e842ec --- /dev/null +++ b/owl-bot-staging/v1alpha2/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# +# google-cloud-gke-hub documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-gke-hub" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-gke-hub-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-gke-hub.tex", + u"google-cloud-gke-hub Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-gke-hub", + u"Google Cloud Gkehub Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-gke-hub", + u"google-cloud-gke-hub Documentation", + author, + "google-cloud-gke-hub", + "GAPIC library for Google Cloud Gkehub API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst new file mode 100644 index 0000000..9a2b4b7 --- /dev/null +++ b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst @@ -0,0 +1,10 @@ +GkeHub +------------------------ + +.. automodule:: google.cloud.gkehub_v1alpha2.services.gke_hub + :members: + :inherited-members: + +.. automodule:: google.cloud.gkehub_v1alpha2.services.gke_hub.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst new file mode 100644 index 0000000..b92fd6f --- /dev/null +++ b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Gkehub v1alpha2 API +============================================= +.. toctree:: + :maxdepth: 2 + + gke_hub diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst new file mode 100644 index 0000000..475cab1 --- /dev/null +++ b/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub v1alpha2 API +========================================== + +.. automodule:: google.cloud.gkehub_v1alpha2.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha2/docs/index.rst b/owl-bot-staging/v1alpha2/docs/index.rst new file mode 100644 index 0000000..c95b286 --- /dev/null +++ b/owl-bot-staging/v1alpha2/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + gkehub_v1alpha2/services + gkehub_v1alpha2/types diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py new file mode 100644 index 0000000..2a00e9b --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub_v1alpha2.services.gke_hub.client import GkeHubClient +from google.cloud.gkehub_v1alpha2.services.gke_hub.async_client import GkeHubAsyncClient + +from google.cloud.gkehub_v1alpha2.types.membership import Authority +from google.cloud.gkehub_v1alpha2.types.membership import ConnectAgentResource +from google.cloud.gkehub_v1alpha2.types.membership import CreateMembershipRequest +from google.cloud.gkehub_v1alpha2.types.membership import DeleteMembershipRequest +from google.cloud.gkehub_v1alpha2.types.membership import GenerateConnectManifestRequest +from google.cloud.gkehub_v1alpha2.types.membership import GenerateConnectManifestResponse +from google.cloud.gkehub_v1alpha2.types.membership import GetMembershipRequest +from google.cloud.gkehub_v1alpha2.types.membership import GkeCluster +from google.cloud.gkehub_v1alpha2.types.membership import InitializeHubRequest +from google.cloud.gkehub_v1alpha2.types.membership import InitializeHubResponse +from google.cloud.gkehub_v1alpha2.types.membership import KubernetesMetadata +from google.cloud.gkehub_v1alpha2.types.membership import KubernetesResource +from google.cloud.gkehub_v1alpha2.types.membership import ListMembershipsRequest +from google.cloud.gkehub_v1alpha2.types.membership import ListMembershipsResponse +from google.cloud.gkehub_v1alpha2.types.membership import Membership +from google.cloud.gkehub_v1alpha2.types.membership import MembershipEndpoint +from google.cloud.gkehub_v1alpha2.types.membership import MembershipState +from google.cloud.gkehub_v1alpha2.types.membership import OperationMetadata +from google.cloud.gkehub_v1alpha2.types.membership import ResourceManifest +from google.cloud.gkehub_v1alpha2.types.membership import ResourceOptions +from google.cloud.gkehub_v1alpha2.types.membership import TypeMeta +from google.cloud.gkehub_v1alpha2.types.membership import UpdateMembershipRequest + +__all__ = ('GkeHubClient', + 'GkeHubAsyncClient', + 'Authority', + 'ConnectAgentResource', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GetMembershipRequest', + 'GkeCluster', + 'InitializeHubRequest', + 'InitializeHubResponse', + 'KubernetesMetadata', + 'KubernetesResource', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'OperationMetadata', + 'ResourceManifest', + 'ResourceOptions', + 'TypeMeta', + 'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed b/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py new file mode 100644 index 0000000..42b9ecb --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .services.gke_hub import GkeHubClient +from .services.gke_hub import GkeHubAsyncClient + +from .types.membership import Authority +from .types.membership import ConnectAgentResource +from .types.membership import CreateMembershipRequest +from .types.membership import DeleteMembershipRequest +from .types.membership import GenerateConnectManifestRequest +from .types.membership import GenerateConnectManifestResponse +from .types.membership import GetMembershipRequest +from .types.membership import GkeCluster +from .types.membership import InitializeHubRequest +from .types.membership import InitializeHubResponse +from .types.membership import KubernetesMetadata +from .types.membership import KubernetesResource +from .types.membership import ListMembershipsRequest +from .types.membership import ListMembershipsResponse +from .types.membership import Membership +from .types.membership import MembershipEndpoint +from .types.membership import MembershipState +from .types.membership import OperationMetadata +from .types.membership import ResourceManifest +from .types.membership import ResourceOptions +from .types.membership import TypeMeta +from .types.membership import UpdateMembershipRequest + +__all__ = ( + 'GkeHubAsyncClient', +'Authority', +'ConnectAgentResource', +'CreateMembershipRequest', +'DeleteMembershipRequest', +'GenerateConnectManifestRequest', +'GenerateConnectManifestResponse', +'GetMembershipRequest', +'GkeCluster', +'GkeHubClient', +'InitializeHubRequest', +'InitializeHubResponse', +'KubernetesMetadata', +'KubernetesResource', +'ListMembershipsRequest', +'ListMembershipsResponse', +'Membership', +'MembershipEndpoint', +'MembershipState', +'OperationMetadata', +'ResourceManifest', +'ResourceOptions', +'TypeMeta', +'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json new file mode 100644 index 0000000..5b70423 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json @@ -0,0 +1,93 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub_v1alpha2", + "protoPackage": "google.cloud.gkehub.v1alpha2", + "schema": "1.0", + "services": { + "GkeHub": { + "clients": { + "grpc": { + "libraryClient": "GkeHubClient", + "rpcs": { + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "InitializeHub": { + "methods": [ + "initialize_hub" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + } + } + }, + "grpc-async": { + "libraryClient": "GkeHubAsyncClient", + "rpcs": { + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "InitializeHub": { + "methods": [ + "initialize_hub" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py new file mode 100644 index 0000000..7304648 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .client import GkeHubClient +from .async_client import GkeHubAsyncClient + +__all__ = ( + 'GkeHubClient', + 'GkeHubAsyncClient', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py new file mode 100644 index 0000000..b68a10b --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py @@ -0,0 +1,775 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha2.types import membership +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport +from .client import GkeHubClient + + +class GkeHubAsyncClient: + """GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + """ + + _client: GkeHubClient + + DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT + + membership_path = staticmethod(GkeHubClient.membership_path) + parse_membership_path = staticmethod(GkeHubClient.parse_membership_path) + common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + common_folder_path = staticmethod(GkeHubClient.common_folder_path) + parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) + common_organization_path = staticmethod(GkeHubClient.common_organization_path) + parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + common_project_path = staticmethod(GkeHubClient.common_project_path) + parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) + common_location_path = staticmethod(GkeHubClient.common_location_path) + parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = GkeHubClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_memberships(self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsAsyncPager: + r"""Lists Memberships in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsRequest`): + The request object. Request message for + `GkeHub.ListMemberships` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1alpha2.services.gke_hub.pagers.ListMembershipsAsyncPager: + Response message for the GkeHub.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 = membership.ListMembershipsRequest(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_memberships, + 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.ListMembershipsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_membership(self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.GetMembershipRequest`): + The request object. Request message for + `GkeHub.GetMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1alpha2.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = membership.GetMembershipRequest(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_membership, + 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 create_membership(self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds a new Membership. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.CreateMembershipRequest`): + The request object. Request message for the + `GkeHub.CreateMembership` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1alpha2.types.Membership`): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (:class:`str`): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha2.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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 = membership.CreateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_membership(self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Membership. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.DeleteMembershipRequest`): + The request object. Request message for + `GkeHub.DeleteMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = membership.DeleteMembershipRequest(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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_membership(self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Membership. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.UpdateMembershipRequest`): + The request object. Request message for + `GkeHub.UpdateMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1alpha2.types.Membership`): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Mask of fields to update. + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha2.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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 = membership.UpdateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def generate_connect_manifest(self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE + connect agent. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.GenerateConnectManifestRequest`): + The request object. Request message for + `GkeHub.GenerateConnectManifest` method. + . + 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.gkehub_v1alpha2.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + request = membership.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.generate_connect_manifest, + 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 initialize_hub(self, + request: membership.InitializeHubRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.InitializeHubResponse: + r"""Initializes the Hub in this project, which includes + creating the default Hub Service Account and the Hub + Workload Identity Pool. Initialization is optional, and + happens automatically when the first Membership is + created. + InitializeHub should be called when the first Membership + cannot be registered without these resources. A common + example is granting the Hub Service Account access to + another project, which requires the account to exist + first. + + Args: + request (:class:`google.cloud.gkehub_v1alpha2.types.InitializeHubRequest`): + The request object. Request message for the + InitializeHub method. + 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.gkehub_v1alpha2.types.InitializeHubResponse: + Response message for the + InitializeHub method. + + """ + # Create or coerce a protobuf request object. + request = membership.InitializeHubRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.initialize_hub, + 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(( + ("project", request.project), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubAsyncClient", +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py new file mode 100644 index 0000000..280eb7c --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py @@ -0,0 +1,964 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha2.types import membership +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import GkeHubGrpcTransport +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +class GkeHubClientMeta(type): + """Metaclass for the GkeHub client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] + _transport_registry["grpc"] = GkeHubGrpcTransport + _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[GkeHubTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class GkeHubClient(metaclass=GkeHubClientMeta): + """GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "gkehub.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def membership_path(project: str,location: str,membership: str,) -> str: + """Returns a fully-qualified membership string.""" + return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + + @staticmethod + def parse_membership_path(path: str) -> Dict[str,str]: + """Parses a membership path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?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, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + 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, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, GkeHubTransport): + # transport is a GkeHubTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def list_memberships(self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsPager: + r"""Lists Memberships in a given project and location. + + Args: + request (google.cloud.gkehub_v1alpha2.types.ListMembershipsRequest): + The request object. Request message for + `GkeHub.ListMemberships` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1alpha2.services.gke_hub.pagers.ListMembershipsPager: + Response message for the GkeHub.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 membership.ListMembershipsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.ListMembershipsRequest): + request = membership.ListMembershipsRequest(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_memberships] + + # 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.ListMembershipsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_membership(self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (google.cloud.gkehub_v1alpha2.types.GetMembershipRequest): + The request object. Request message for + `GkeHub.GetMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1alpha2.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a membership.GetMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.GetMembershipRequest): + request = membership.GetMembershipRequest(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_membership] + + # 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 create_membership(self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds a new Membership. + + Args: + request (google.cloud.gkehub_v1alpha2.types.CreateMembershipRequest): + The request object. Request message for the + `GkeHub.CreateMembership` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1alpha2.types.Membership): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha2.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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 membership.CreateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.CreateMembershipRequest): + request = membership.CreateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_membership] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_membership(self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Membership. + + Args: + request (google.cloud.gkehub_v1alpha2.types.DeleteMembershipRequest): + The request object. Request message for + `GkeHub.DeleteMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a membership.DeleteMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.DeleteMembershipRequest): + request = membership.DeleteMembershipRequest(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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_membership(self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Membership. + + Args: + request (google.cloud.gkehub_v1alpha2.types.UpdateMembershipRequest): + The request object. Request message for + `GkeHub.UpdateMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1alpha2.types.Membership): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1alpha2.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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 membership.UpdateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.UpdateMembershipRequest): + request = membership.UpdateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def generate_connect_manifest(self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE + connect agent. + + Args: + request (google.cloud.gkehub_v1alpha2.types.GenerateConnectManifestRequest): + The request object. Request message for + `GkeHub.GenerateConnectManifest` method. + . + 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.gkehub_v1alpha2.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a membership.GenerateConnectManifestRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.GenerateConnectManifestRequest): + request = membership.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] + + # 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 initialize_hub(self, + request: membership.InitializeHubRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.InitializeHubResponse: + r"""Initializes the Hub in this project, which includes + creating the default Hub Service Account and the Hub + Workload Identity Pool. Initialization is optional, and + happens automatically when the first Membership is + created. + InitializeHub should be called when the first Membership + cannot be registered without these resources. A common + example is granting the Hub Service Account access to + another project, which requires the account to exist + first. + + Args: + request (google.cloud.gkehub_v1alpha2.types.InitializeHubRequest): + The request object. Request message for the + InitializeHub method. + 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.gkehub_v1alpha2.types.InitializeHubResponse: + Response message for the + InitializeHub method. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a membership.InitializeHubRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.InitializeHubRequest): + request = membership.InitializeHubRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.initialize_hub] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("project", request.project), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubClient", +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py new file mode 100644 index 0000000..3467a04 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.gkehub_v1alpha2.types import membership + + +class ListMembershipsPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` + 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[..., membership.ListMembershipsResponse], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + 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.gkehub_v1alpha2.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse): + 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 = membership.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[membership.ListMembershipsResponse]: + 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) -> Iterable[membership.Membership]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListMembershipsAsyncPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` + 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[membership.ListMembershipsResponse]], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + 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.gkehub_v1alpha2.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse): + 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 = membership.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[membership.ListMembershipsResponse]: + 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) -> AsyncIterable[membership.Membership]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py new file mode 100644 index 0000000..29c1c45 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import GkeHubTransport +from .grpc import GkeHubGrpcTransport +from .grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] +_transport_registry['grpc'] = GkeHubGrpcTransport +_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport + +__all__ = ( + 'GkeHubTransport', + 'GkeHubGrpcTransport', + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py new file mode 100644 index 0000000..128d108 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py @@ -0,0 +1,259 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.gkehub_v1alpha2.types import membership +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-gke-hub', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class GkeHubTransport(abc.ABC): + """Abstract transport class for GkeHub.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'gkehub.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + 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' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_memberships: gapic_v1.method.wrap_method( + self.list_memberships, + default_timeout=None, + client_info=client_info, + ), + self.get_membership: gapic_v1.method.wrap_method( + self.get_membership, + default_timeout=None, + client_info=client_info, + ), + self.create_membership: gapic_v1.method.wrap_method( + self.create_membership, + default_timeout=None, + client_info=client_info, + ), + self.delete_membership: gapic_v1.method.wrap_method( + self.delete_membership, + default_timeout=None, + client_info=client_info, + ), + self.update_membership: gapic_v1.method.wrap_method( + self.update_membership, + default_timeout=None, + client_info=client_info, + ), + self.generate_connect_manifest: gapic_v1.method.wrap_method( + self.generate_connect_manifest, + default_timeout=None, + client_info=client_info, + ), + self.initialize_hub: gapic_v1.method.wrap_method( + self.initialize_hub, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + Union[ + membership.ListMembershipsResponse, + Awaitable[membership.ListMembershipsResponse] + ]]: + raise NotImplementedError() + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + Union[ + membership.Membership, + Awaitable[membership.Membership] + ]]: + raise NotImplementedError() + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + Union[ + membership.GenerateConnectManifestResponse, + Awaitable[membership.GenerateConnectManifestResponse] + ]]: + raise NotImplementedError() + + @property + def initialize_hub(self) -> Callable[ + [membership.InitializeHubRequest], + Union[ + membership.InitializeHubResponse, + Awaitable[membership.InitializeHubResponse] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'GkeHubTransport', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py new file mode 100644 index 0000000..c8a7903 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py @@ -0,0 +1,436 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.gkehub_v1alpha2.types import membership +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO + + +class GkeHubGrpcTransport(GkeHubTransport): + """gRPC backend transport for GkeHub. + + GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + membership.ListMembershipsResponse]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + ~.ListMembershipsResponse]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships', + request_serializer=membership.ListMembershipsRequest.serialize, + response_deserializer=membership.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + membership.Membership]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + ~.Membership]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership', + request_serializer=membership.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the create membership method over gRPC. + + Adds a new Membership. + + Returns: + Callable[[~.CreateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership', + request_serializer=membership.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + Returns: + Callable[[~.DeleteMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership', + request_serializer=membership.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership', + request_serializer=membership.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + membership.GenerateConnectManifestResponse]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE + connect agent. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + ~.GenerateConnectManifestResponse]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest', + request_serializer=membership.GenerateConnectManifestRequest.serialize, + response_deserializer=membership.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + @property + def initialize_hub(self) -> Callable[ + [membership.InitializeHubRequest], + membership.InitializeHubResponse]: + r"""Return a callable for the initialize hub method over gRPC. + + Initializes the Hub in this project, which includes + creating the default Hub Service Account and the Hub + Workload Identity Pool. Initialization is optional, and + happens automatically when the first Membership is + created. + InitializeHub should be called when the first Membership + cannot be registered without these resources. A common + example is granting the Hub Service Account access to + another project, which requires the account to exist + first. + + Returns: + Callable[[~.InitializeHubRequest], + ~.InitializeHubResponse]: + 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 'initialize_hub' not in self._stubs: + self._stubs['initialize_hub'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub', + request_serializer=membership.InitializeHubRequest.serialize, + response_deserializer=membership.InitializeHubResponse.deserialize, + ) + return self._stubs['initialize_hub'] + + +__all__ = ( + 'GkeHubGrpcTransport', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py new file mode 100644 index 0000000..7b5d4d3 --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py @@ -0,0 +1,440 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.gkehub_v1alpha2.types import membership +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .grpc import GkeHubGrpcTransport + + +class GkeHubGrpcAsyncIOTransport(GkeHubTransport): + """gRPC AsyncIO backend transport for GkeHub. + + GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + Awaitable[membership.ListMembershipsResponse]]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + Awaitable[~.ListMembershipsResponse]]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships', + request_serializer=membership.ListMembershipsRequest.serialize, + response_deserializer=membership.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + Awaitable[membership.Membership]]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + Awaitable[~.Membership]]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership', + request_serializer=membership.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create membership method over gRPC. + + Adds a new Membership. + + Returns: + Callable[[~.CreateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership', + request_serializer=membership.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + Returns: + Callable[[~.DeleteMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership', + request_serializer=membership.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership', + request_serializer=membership.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + Awaitable[membership.GenerateConnectManifestResponse]]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE + connect agent. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + Awaitable[~.GenerateConnectManifestResponse]]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest', + request_serializer=membership.GenerateConnectManifestRequest.serialize, + response_deserializer=membership.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + @property + def initialize_hub(self) -> Callable[ + [membership.InitializeHubRequest], + Awaitable[membership.InitializeHubResponse]]: + r"""Return a callable for the initialize hub method over gRPC. + + Initializes the Hub in this project, which includes + creating the default Hub Service Account and the Hub + Workload Identity Pool. Initialization is optional, and + happens automatically when the first Membership is + created. + InitializeHub should be called when the first Membership + cannot be registered without these resources. A common + example is granting the Hub Service Account access to + another project, which requires the account to exist + first. + + Returns: + Callable[[~.InitializeHubRequest], + Awaitable[~.InitializeHubResponse]]: + 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 'initialize_hub' not in self._stubs: + self._stubs['initialize_hub'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub', + request_serializer=membership.InitializeHubRequest.serialize, + response_deserializer=membership.InitializeHubResponse.deserialize, + ) + return self._stubs['initialize_hub'] + + +__all__ = ( + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py new file mode 100644 index 0000000..92abd8e --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .membership import ( + Authority, + ConnectAgentResource, + CreateMembershipRequest, + DeleteMembershipRequest, + GenerateConnectManifestRequest, + GenerateConnectManifestResponse, + GetMembershipRequest, + GkeCluster, + InitializeHubRequest, + InitializeHubResponse, + KubernetesMetadata, + KubernetesResource, + ListMembershipsRequest, + ListMembershipsResponse, + Membership, + MembershipEndpoint, + MembershipState, + OperationMetadata, + ResourceManifest, + ResourceOptions, + TypeMeta, + UpdateMembershipRequest, +) + +__all__ = ( + 'Authority', + 'ConnectAgentResource', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GetMembershipRequest', + 'GkeCluster', + 'InitializeHubRequest', + 'InitializeHubResponse', + 'KubernetesMetadata', + 'KubernetesResource', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'OperationMetadata', + 'ResourceManifest', + 'ResourceOptions', + 'TypeMeta', + 'UpdateMembershipRequest', +) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py new file mode 100644 index 0000000..cf34a7e --- /dev/null +++ b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py @@ -0,0 +1,952 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1alpha2', + manifest={ + 'Membership', + 'MembershipEndpoint', + 'KubernetesResource', + 'ResourceOptions', + 'GkeCluster', + 'KubernetesMetadata', + 'Authority', + 'MembershipState', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'GetMembershipRequest', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'UpdateMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'ConnectAgentResource', + 'ResourceManifest', + 'TypeMeta', + 'InitializeHubRequest', + 'InitializeHubResponse', + 'OperationMetadata', + }, +) + + +class Membership(proto.Message): + r"""Membership contains information about a member cluster. + Attributes: + name (str): + Output only. The full, unique name of this Membership + resource in the format + ``projects/*/locations/*/memberships/{membership_id}``, set + during creation. + + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + labels (Sequence[google.cloud.gkehub_v1alpha2.types.Membership.LabelsEntry]): + Optional. GCP labels for this membership. + description (str): + Output only. Description of this membership, limited to 63 + characters. Must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.\ ]*`` + + This field is present for legacy purposes. + endpoint (google.cloud.gkehub_v1alpha2.types.MembershipEndpoint): + Optional. Endpoint information to reach this + member. + state (google.cloud.gkehub_v1alpha2.types.MembershipState): + Output only. State of the Membership + resource. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was last + updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was deleted. + external_id (str): + Optional. An externally-generated and managed ID for this + Membership. This ID may be modified after creation, but this + is not recommended. For GKE clusters, external_id is managed + by the Hub API and updates will be ignored. + + The ID must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.]*`` + + If this Membership represents a Kubernetes cluster, this + value should be set to the UID of the ``kube-system`` + namespace object. + authority (google.cloud.gkehub_v1alpha2.types.Authority): + Optional. How to identify workloads from this + Membership. See the documentation on Workload + Identity for more details: + https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + last_connection_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. For clusters using Connect, the + timestamp of the most recent connection + established with Google Cloud. This time is + updated every several minutes, not continuously. + For clusters that do not use GKE Connect, or + that have never connected successfully, this + field will be unset. + unique_id (str): + Output only. Google-generated UUID for this resource. This + is unique across all Membership resources. If a Membership + resource is deleted and another resource with the same name + is created, it gets a different unique_id. + infrastructure_type (google.cloud.gkehub_v1alpha2.types.Membership.InfrastructureType): + Optional. The infrastructure type this + Membership is running on. + """ + class InfrastructureType(proto.Enum): + r"""Specifies the infrastructure type of a Membership. + Infrastructure type is used by Hub to control infrastructure- + specific behavior, including pricing. + Each GKE distribution (on-GCP, on-Prem, on-X,...) will set this + field automatically, but Attached Clusters customers should + specify a type during registration. + """ + INFRASTRUCTURE_TYPE_UNSPECIFIED = 0 + ON_PREM = 1 + MULTI_CLOUD = 2 + + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + description = proto.Field( + proto.STRING, + number=3, + ) + endpoint = proto.Field( + proto.MESSAGE, + number=4, + oneof='type', + message='MembershipEndpoint', + ) + state = proto.Field( + proto.MESSAGE, + number=5, + message='MembershipState', + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + external_id = proto.Field( + proto.STRING, + number=9, + ) + authority = proto.Field( + proto.MESSAGE, + number=10, + message='Authority', + ) + last_connection_time = proto.Field( + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + unique_id = proto.Field( + proto.STRING, + number=12, + ) + infrastructure_type = proto.Field( + proto.ENUM, + number=13, + enum=InfrastructureType, + ) + + +class MembershipEndpoint(proto.Message): + r"""MembershipEndpoint contains information needed to contact a + Kubernetes API, endpoint and any additional Kubernetes metadata. + + Attributes: + gke_cluster (google.cloud.gkehub_v1alpha2.types.GkeCluster): + Optional. GKE-specific information. Only + present if this Membership is a GKE cluster. + kubernetes_metadata (google.cloud.gkehub_v1alpha2.types.KubernetesMetadata): + Output only. Useful Kubernetes-specific + metadata. + kubernetes_resource (google.cloud.gkehub_v1alpha2.types.KubernetesResource): + Optional. The in-cluster Kubernetes Resources that should be + applied for a correctly registered cluster, in the steady + state. These resources: + + - Ensure that the cluster is exclusively registered to one + and only one Hub Membership. + - Propagate Workload Pool Information available in the + Membership Authority field. + - Ensure proper initial configuration of default Hub + Features. + """ + + gke_cluster = proto.Field( + proto.MESSAGE, + number=1, + message='GkeCluster', + ) + kubernetes_metadata = proto.Field( + proto.MESSAGE, + number=2, + message='KubernetesMetadata', + ) + kubernetes_resource = proto.Field( + proto.MESSAGE, + number=3, + message='KubernetesResource', + ) + + +class KubernetesResource(proto.Message): + r"""KubernetesResource contains the YAML manifests and + configuration for Membership Kubernetes resources in the + cluster. After CreateMembership or UpdateMembership, these + resources should be re-applied in the cluster. + + Attributes: + membership_cr_manifest (str): + Input only. The YAML representation of the + Membership CR. This field is ignored for GKE + clusters where Hub can read the CR directly. + Callers should provide the CR that is currently + present in the cluster during Create or Update, + or leave this field empty if none exists. The CR + manifest is used to validate the cluster has not + been registered with another Membership. + membership_resources (Sequence[google.cloud.gkehub_v1alpha2.types.ResourceManifest]): + Output only. Additional Kubernetes resources + that need to be applied to the cluster after + Membership creation, and after every update. + This field is only populated in the Membership + returned from a successful long-running + operation from CreateMembership or + UpdateMembership. It is not populated during + normal GetMembership or ListMemberships + requests. To get the resource manifest after the + initial registration, the caller should make a + UpdateMembership call with an empty field mask. + connect_resources (Sequence[google.cloud.gkehub_v1alpha2.types.ResourceManifest]): + Output only. The Kubernetes resources for + installing the GKE Connect agent. + This field is only populated in the Membership + returned from a successful long-running + operation from CreateMembership or + UpdateMembership. It is not populated during + normal GetMembership or ListMemberships + requests. To get the resource manifest after the + initial registration, the caller should make a + UpdateMembership call with an empty field mask. + resource_options (google.cloud.gkehub_v1alpha2.types.ResourceOptions): + Optional. Options for Kubernetes resource + generation. + """ + + membership_cr_manifest = proto.Field( + proto.STRING, + number=1, + ) + membership_resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ResourceManifest', + ) + connect_resources = proto.RepeatedField( + proto.MESSAGE, + number=4, + message='ResourceManifest', + ) + resource_options = proto.Field( + proto.MESSAGE, + number=5, + message='ResourceOptions', + ) + + +class ResourceOptions(proto.Message): + r"""ResourceOptions represent options for Kubernetes resource + generation. + + Attributes: + connect_version (str): + Optional. The Connect agent version to use for + connect_resources. Defaults to the latest GKE Connect + version. The version must be a currently supported version, + obsolete versions will be rejected. + v1beta1_crd (bool): + Optional. Use ``apiextensions/v1beta1`` instead of + ``apiextensions/v1`` for CustomResourceDefinition resources. + This option should be set for clusters with Kubernetes + apiserver versions <1.16. + """ + + connect_version = proto.Field( + proto.STRING, + number=1, + ) + v1beta1_crd = proto.Field( + proto.BOOL, + number=2, + ) + + +class GkeCluster(proto.Message): + r"""GkeCluster contains information specific to GKE clusters. + Attributes: + resource_link (str): + Immutable. Self-link of the GCP resource for + the GKE cluster. For example: + //container.googleapis.com/projects/my- + project/locations/us-west1-a/clusters/my-cluster + Zonal clusters are also supported. + """ + + resource_link = proto.Field( + proto.STRING, + number=1, + ) + + +class KubernetesMetadata(proto.Message): + r"""KubernetesMetadata provides informational metadata for + Memberships that are created from Kubernetes Endpoints + (currently, these are equivalent to Kubernetes clusters). + + Attributes: + kubernetes_api_server_version (str): + Output only. Kubernetes API server version + string as reported by '/version'. + node_provider_id (str): + Output only. Node providerID as reported by the first node + in the list of nodes on the Kubernetes endpoint. On + Kubernetes platforms that support zero-node clusters (like + GKE-on-GCP), the node_count will be zero and the + node_provider_id will be empty. + node_count (int): + Output only. Node count as reported by + Kubernetes nodes resources. + vcpu_count (int): + Output only. vCPU count as reported by + Kubernetes nodes resources. + memory_mb (int): + Output only. The total memory capacity as + reported by the sum of all Kubernetes nodes + resources, defined in MB. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which these details were last + updated. This update_time is different from the + Membership-level update_time since EndpointDetails are + updated internally for API consumers. + """ + + kubernetes_api_server_version = proto.Field( + proto.STRING, + number=1, + ) + node_provider_id = proto.Field( + proto.STRING, + number=2, + ) + node_count = proto.Field( + proto.INT32, + number=3, + ) + vcpu_count = proto.Field( + proto.INT32, + number=4, + ) + memory_mb = proto.Field( + proto.INT32, + number=5, + ) + update_time = proto.Field( + proto.MESSAGE, + number=100, + message=timestamp_pb2.Timestamp, + ) + + +class Authority(proto.Message): + r"""Authority encodes how Google will recognize identities from + this Membership. See the workload identity documentation for + more details: https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + + Attributes: + issuer (str): + Optional. A JSON Web Token (JWT) issuer URI. ``issuer`` must + start with ``https://`` and be a valid URL with length <2000 + characters. + + If set, then Google will allow valid OIDC tokens from this + issuer to authenticate within the workload_identity_pool. + OIDC discovery will be performed on this URI to validate + tokens from the issuer, unless ``oidc_jwks`` is set. + + Clearing ``issuer`` disables Workload Identity. ``issuer`` + cannot be directly modified; it must be cleared (and + Workload Identity disabled) before using a new issuer (and + re-enabling Workload Identity). + oidc_jwks (bytes): + Optional. OIDC verification keys for this Membership in JWKS + format (RFC 7517). + + When this field is set, OIDC discovery will NOT be performed + on ``issuer``, and instead OIDC tokens will be validated + using this field. + identity_provider (str): + Output only. An identity provider that reflects the + ``issuer`` in the workload identity pool. + workload_identity_pool (str): + Output only. The name of the workload identity pool in which + ``issuer`` will be recognized. + + There is a single Workload Identity Pool per Hub that is + shared between all Memberships that belong to that Hub. For + a Hub hosted in {PROJECT_ID}, the workload pool format is + ``{PROJECT_ID}.hub.id.goog``, although this is subject to + change in newer versions of this API. + """ + + issuer = proto.Field( + proto.STRING, + number=1, + ) + oidc_jwks = proto.Field( + proto.BYTES, + number=5, + ) + identity_provider = proto.Field( + proto.STRING, + number=3, + ) + workload_identity_pool = proto.Field( + proto.STRING, + number=4, + ) + + +class MembershipState(proto.Message): + r"""MembershipState describes the state of a Membership resource. + Attributes: + code (google.cloud.gkehub_v1alpha2.types.MembershipState.Code): + Output only. The current state of the + Membership resource. + """ + class Code(proto.Enum): + r"""Code describes the state of a Membership resource.""" + CODE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + + +class ListMembershipsRequest(proto.Message): + r"""Request message for ``GkeHub.ListMemberships`` method. + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/locations/*``. + page_size (int): + Optional. When requesting a 'page' of resources, + ``page_size`` specifies number of resources to return. If + unspecified or set to 0, all resources will be returned. + page_token (str): + Optional. Token returned by previous call to + ``ListMemberships`` which specifies the position in the list + from where to continue listing the resources. + filter (str): + Optional. Lists Memberships that match the filter + expression, following the syntax outlined in + https://google.aip.dev/160. + + Examples: + + - Name is ``bar`` in project ``foo-proj`` and location + ``global``: + + name = + "projects/foo-proj/locations/global/membership/bar" + + - Memberships that have a label called ``foo``: + + labels.foo:\* + + - Memberships that have a label called ``foo`` whose value + is ``bar``: + + labels.foo = bar + + - Memberships in the CREATING state: + + state = CREATING + order_by (str): + Optional. One or more fields to compare and + use to sort the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListMembershipsResponse(proto.Message): + r"""Response message for the ``GkeHub.ListMemberships`` method. + Attributes: + resources (Sequence[google.cloud.gkehub_v1alpha2.types.Membership]): + The list of matching Memberships. + next_page_token (str): + A token to request the next page of resources from the + ``ListMemberships`` method. The value of an empty string + means that there are no more resources to return. + unreachable (Sequence[str]): + List of locations that could not be reached + while fetching this list. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Membership', + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.GetMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateMembershipRequest(proto.Message): + r"""Request message for the ``GkeHub.CreateMembership`` method. + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + resource (google.cloud.gkehub_v1alpha2.types.Membership): + Required. The membership to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + membership_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message='Membership', + ) + + +class DeleteMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.DeleteMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateMembershipRequest(proto.Message): + r"""Request message for ``GkeHub.UpdateMembership`` method. + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + resource (google.cloud.gkehub_v1alpha2.types.Membership): + Required. Only fields specified in update_mask are updated. + If you specify a field in the update_mask but don't specify + its value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message='Membership', + ) + + +class GenerateConnectManifestRequest(proto.Message): + r"""Request message for ``GkeHub.GenerateConnectManifest`` method. . + Attributes: + name (str): + Required. The Membership resource name the Agent will + associate with, in the format + ``projects/*/locations/*/memberships/*``. + namespace (str): + Optional. Namespace for GKE Connect agent resources. + Defaults to ``gke-connect``. + + The Connect Agent is authorized automatically when run in + the default namespace. Otherwise, explicit authorization + must be granted with an additional IAM binding. + proxy (bytes): + Optional. URI of a proxy if connectivity from the agent to + gkeconnect.googleapis.com requires the use of a proxy. + Format must be in the form ``http(s)://{proxy_address}``, + depending on the HTTP/HTTPS protocol supported by the proxy. + This will direct the connect agent's outbound traffic + through a HTTP(S) proxy. + version (str): + Optional. The Connect agent version to use. + Defaults to the most current version. + is_upgrade (bool): + Optional. If true, generate the resources for + upgrade only. Some resources generated only for + installation (e.g. secrets) will be excluded. + registry (str): + Optional. The registry to fetch the connect + agent image from. Defaults to gcr.io/gkeconnect. + image_pull_secret_content (bytes): + Optional. The image pull secret content for + the registry, if not public. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + namespace = proto.Field( + proto.STRING, + number=2, + ) + proxy = proto.Field( + proto.BYTES, + number=3, + ) + version = proto.Field( + proto.STRING, + number=4, + ) + is_upgrade = proto.Field( + proto.BOOL, + number=5, + ) + registry = proto.Field( + proto.STRING, + number=6, + ) + image_pull_secret_content = proto.Field( + proto.BYTES, + number=7, + ) + + +class GenerateConnectManifestResponse(proto.Message): + r"""GenerateConnectManifestResponse contains manifest information + for installing/upgrading a Connect agent. + + Attributes: + manifest (Sequence[google.cloud.gkehub_v1alpha2.types.ConnectAgentResource]): + The ordered list of Kubernetes resources that + need to be applied to the cluster for GKE + Connect agent installation/upgrade. + """ + + manifest = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='ConnectAgentResource', + ) + + +class ConnectAgentResource(proto.Message): + r"""ConnectAgentResource represents a Kubernetes resource + manifest for Connect Agent deployment. + + Attributes: + type_ (google.cloud.gkehub_v1alpha2.types.TypeMeta): + Kubernetes type of the resource. + manifest (str): + YAML manifest of the resource. + """ + + type_ = proto.Field( + proto.MESSAGE, + number=1, + message='TypeMeta', + ) + manifest = proto.Field( + proto.STRING, + number=2, + ) + + +class ResourceManifest(proto.Message): + r"""ResourceManifest represents a single Kubernetes resource to + be applied to the cluster. + + Attributes: + manifest (str): + YAML manifest of the resource. + cluster_scoped (bool): + Whether the resource provided in the manifest is + ``cluster_scoped``. If unset, the manifest is assumed to be + namespace scoped. + + This field is used for REST mapping when applying the + resource in a cluster. + """ + + manifest = proto.Field( + proto.STRING, + number=1, + ) + cluster_scoped = proto.Field( + proto.BOOL, + number=2, + ) + + +class TypeMeta(proto.Message): + r"""TypeMeta is the type information needed for content + unmarshalling of Kubernetes resources in the manifest. + + Attributes: + kind (str): + Kind of the resource (e.g. Deployment). + api_version (str): + APIVersion of the resource (e.g. v1). + """ + + kind = proto.Field( + proto.STRING, + number=1, + ) + api_version = proto.Field( + proto.STRING, + number=2, + ) + + +class InitializeHubRequest(proto.Message): + r"""Request message for the InitializeHub method. + Attributes: + project (str): + Required. The Hub to initialize, in the format + ``projects/*/locations/*/memberships/*``. + """ + + project = proto.Field( + proto.STRING, + number=1, + ) + + +class InitializeHubResponse(proto.Message): + r"""Response message for the InitializeHub method. + Attributes: + service_identity (str): + Name of the Hub default service identity, in the format: + + :: + + service-@gcp-sa-gkehub.iam.gserviceaccount.com + + The service account has ``roles/gkehub.serviceAgent`` in the + Hub project. + workload_identity_pool (str): + The Workload Identity Pool used for Workload + Identity-enabled clusters registered with this Hub. Format: + ``.hub.id.goog`` + """ + + service_identity = proto.Field( + proto.STRING, + number=1, + ) + workload_identity_pool = proto.Field( + proto.STRING, + number=2, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_detail (str): + Output only. Human-readable status of the + operation, if any. + cancel_requested (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha2/mypy.ini b/owl-bot-staging/v1alpha2/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1alpha2/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1alpha2/noxfile.py b/owl-bot-staging/v1alpha2/noxfile.py new file mode 100644 index 0000000..60daabe --- /dev/null +++ b/owl-bot-staging/v1alpha2/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/gkehub_v1alpha2/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py b/owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py new file mode 100644 index 0000000..830ead8 --- /dev/null +++ b/owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py @@ -0,0 +1,182 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class gkehubCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_membership': ('parent', 'membership_id', 'resource', ), + 'delete_membership': ('name', ), + 'generate_connect_manifest': ('name', 'namespace', 'proxy', 'version', 'is_upgrade', 'registry', 'image_pull_secret_content', ), + 'get_membership': ('name', ), + 'initialize_hub': ('project', ), + 'list_memberships': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_membership': ('name', 'update_mask', 'resource', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=gkehubCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the gkehub client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1alpha2/setup.py b/owl-bot-staging/v1alpha2/setup.py new file mode 100644 index 0000000..2c5fa00 --- /dev/null +++ b/owl-bot-staging/v1alpha2/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-gke-hub', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1alpha2/tests/__init__.py b/owl-bot-staging/v1alpha2/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha2/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/tests/unit/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha2/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py b/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py new file mode 100644 index 0000000..bf6e3b1 --- /dev/null +++ b/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py @@ -0,0 +1,2654 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +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 operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.gkehub_v1alpha2.services.gke_hub import GkeHubAsyncClient +from google.cloud.gkehub_v1alpha2.services.gke_hub import GkeHubClient +from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers +from google.cloud.gkehub_v1alpha2.services.gke_hub import transports +from google.cloud.gkehub_v1alpha2.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1alpha2.types import membership +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert GkeHubClient._get_default_mtls_endpoint(None) is None + assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_service_account_always_use_jwt(client_class): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_file(client_class): + 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") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_client_get_transport_class(): + transport = GkeHubClient.get_transport_class() + available_transports = [ + transports.GkeHubGrpcTransport, + ] + assert transport in available_transports + + transport = GkeHubClient.get_transport_class("grpc") + assert transport == transports.GkeHubGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +def test_gke_hub_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + 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) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_gke_hub_client_client_options_from_dict(): + with mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = GkeHubClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_list_memberships(transport: str = 'grpc', request_type=membership.ListMembershipsRequest): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_memberships(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_memberships_from_dict(): + test_list_memberships(request_type=dict) + + +def test_list_memberships_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 = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + client.list_memberships() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + +@pytest.mark.asyncio +async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=membership.ListMembershipsRequest): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_memberships(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_memberships_async_from_dict(): + await test_list_memberships_async(request_type=dict) + + +def test_list_memberships_field_headers(): + client = GkeHubClient( + 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 = membership.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = membership.ListMembershipsResponse() + client.list_memberships(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_memberships_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + await client.list_memberships(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_memberships_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_memberships_flattened_error(): + client = GkeHubClient( + 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_memberships( + membership.ListMembershipsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_error_async(): + client = GkeHubAsyncClient( + 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_memberships( + membership.ListMembershipsRequest(), + parent='parent_value', + ) + + +def test_list_memberships_pager(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_memberships(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, membership.Membership) + for i in results) + +def test_list_memberships_pages(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = list(client.list_memberships(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_memberships_async_pager(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_memberships(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, membership.Membership) + for i in responses) + +@pytest.mark.asyncio +async def test_list_memberships_async_pages(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_memberships(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_membership(transport: str = 'grpc', request_type=membership.GetMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, + endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), + ) + response = client.get_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + + +def test_get_membership_from_dict(): + test_get_membership(request_type=dict) + + +def test_get_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.get_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + +@pytest.mark.asyncio +async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=membership.GetMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, + )) + response = await client.get_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + + +@pytest.mark.asyncio +async def test_get_membership_async_from_dict(): + await test_get_membership_async(request_type=dict) + + +def test_get_membership_field_headers(): + client = GkeHubClient( + 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 = membership.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = membership.Membership() + client.get_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + await client.get_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + membership.GetMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + membership.GetMembershipRequest(), + name='name_value', + ) + + +def test_create_membership(transport: str = 'grpc', request_type=membership.CreateMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_membership_from_dict(): + test_create_membership(request_type=dict) + + +def test_create_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.create_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + +@pytest.mark.asyncio +async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=membership.CreateMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_membership_async_from_dict(): + await test_create_membership_async(request_type=dict) + + +def test_create_membership_field_headers(): + client = GkeHubClient( + 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 = membership.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_membership( + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].membership_id == 'membership_id_value' + + +def test_create_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + membership.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_membership( + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].membership_id == 'membership_id_value' + + +@pytest.mark.asyncio +async def test_create_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + membership.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_id_value', + ) + + +def test_delete_membership(transport: str = 'grpc', request_type=membership.DeleteMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_membership_from_dict(): + test_delete_membership(request_type=dict) + + +def test_delete_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.delete_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + +@pytest.mark.asyncio +async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=membership.DeleteMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_membership_async_from_dict(): + await test_delete_membership_async(request_type=dict) + + +def test_delete_membership_field_headers(): + client = GkeHubClient( + 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 = membership.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_membership(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_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_membership(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_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + membership.DeleteMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + membership.DeleteMembershipRequest(), + name='name_value', + ) + + +def test_update_membership(transport: str = 'grpc', request_type=membership.UpdateMembershipRequest): + client = GkeHubClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_membership_from_dict(): + test_update_membership(request_type=dict) + + +def test_update_membership_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 = GkeHubClient( + 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_membership), + '__call__') as call: + client.update_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + +@pytest.mark.asyncio +async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=membership.UpdateMembershipRequest): + client = GkeHubAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_membership_async_from_dict(): + await test_update_membership_async(request_type=dict) + + +def test_update_membership_field_headers(): + client = GkeHubClient( + 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 = membership.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_membership(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_update_membership_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_membership(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_update_membership_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_membership( + name='name_value', + resource=membership.Membership(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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_membership_flattened_error(): + client = GkeHubClient( + 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_membership( + membership.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_membership( + name='name_value', + resource=membership.Membership(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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_error_async(): + client = GkeHubAsyncClient( + 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_membership( + membership.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_generate_connect_manifest(transport: str = 'grpc', request_type=membership.GenerateConnectManifestRequest): + client = GkeHubClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.GenerateConnectManifestResponse( + ) + response = client.generate_connect_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateConnectManifestResponse) + + +def test_generate_connect_manifest_from_dict(): + test_generate_connect_manifest(request_type=dict) + + +def test_generate_connect_manifest_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 = GkeHubClient( + 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.generate_connect_manifest), + '__call__') as call: + client.generate_connect_manifest() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateConnectManifestRequest): + client = GkeHubAsyncClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse( + )) + response = await client.generate_connect_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateConnectManifestResponse) + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async_from_dict(): + await test_generate_connect_manifest_async(request_type=dict) + + +def test_generate_connect_manifest_field_headers(): + client = GkeHubClient( + 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 = membership.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = membership.GenerateConnectManifestResponse() + client.generate_connect_manifest(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_generate_connect_manifest_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse()) + await client.generate_connect_manifest(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_initialize_hub(transport: str = 'grpc', request_type=membership.InitializeHubRequest): + client = GkeHubClient( + 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.initialize_hub), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.InitializeHubResponse( + service_identity='service_identity_value', + workload_identity_pool='workload_identity_pool_value', + ) + response = client.initialize_hub(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.InitializeHubRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.InitializeHubResponse) + assert response.service_identity == 'service_identity_value' + assert response.workload_identity_pool == 'workload_identity_pool_value' + + +def test_initialize_hub_from_dict(): + test_initialize_hub(request_type=dict) + + +def test_initialize_hub_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 = GkeHubClient( + 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.initialize_hub), + '__call__') as call: + client.initialize_hub() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.InitializeHubRequest() + + +@pytest.mark.asyncio +async def test_initialize_hub_async(transport: str = 'grpc_asyncio', request_type=membership.InitializeHubRequest): + client = GkeHubAsyncClient( + 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.initialize_hub), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.InitializeHubResponse( + service_identity='service_identity_value', + workload_identity_pool='workload_identity_pool_value', + )) + response = await client.initialize_hub(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.InitializeHubRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.InitializeHubResponse) + assert response.service_identity == 'service_identity_value' + assert response.workload_identity_pool == 'workload_identity_pool_value' + + +@pytest.mark.asyncio +async def test_initialize_hub_async_from_dict(): + await test_initialize_hub_async(request_type=dict) + + +def test_initialize_hub_field_headers(): + client = GkeHubClient( + 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 = membership.InitializeHubRequest() + + request.project = 'project/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.initialize_hub), + '__call__') as call: + call.return_value = membership.InitializeHubResponse() + client.initialize_hub(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', + 'project=project/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_initialize_hub_field_headers_async(): + client = GkeHubAsyncClient( + 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 = membership.InitializeHubRequest() + + request.project = 'project/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.initialize_hub), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.InitializeHubResponse()) + await client.initialize_hub(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', + 'project=project/value', + ) in kw['metadata'] + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = GkeHubClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.GkeHubGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, +]) +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() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.GkeHubGrpcTransport, + ) + +def test_gke_hub_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_gke_hub_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_memberships', + 'get_membership', + 'create_membership', + 'delete_membership', + 'update_membership', + 'generate_connect_manifest', + 'initialize_hub', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_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('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): + # 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('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_gke_hub_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_gke_hub_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.GkeHubGrpcTransport, grpc_helpers), + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "gkehub.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="gkehub.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_gke_hub_host_no_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + ) + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_host_with_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + ) + assert client.transport._host == 'gkehub.googleapis.com:8000' + +def test_gke_hub_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_gke_hub_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_gke_hub_grpc_lro_client(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_gke_hub_grpc_lro_async_client(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_membership_path(): + project = "squid" + location = "clam" + membership = "whelk" + expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + actual = GkeHubClient.membership_path(project, location, membership) + assert expected == actual + + +def test_parse_membership_path(): + expected = { + "project": "octopus", + "location": "oyster", + "membership": "nudibranch", + } + path = GkeHubClient.membership_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_membership_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = GkeHubClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = GkeHubClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = GkeHubClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = GkeHubClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = GkeHubClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = GkeHubClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = GkeHubClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = GkeHubClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = GkeHubClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = GkeHubClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + transport_class = GkeHubClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1beta/.coveragerc b/owl-bot-staging/v1beta/.coveragerc new file mode 100644 index 0000000..3cef77b --- /dev/null +++ b/owl-bot-staging/v1beta/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/gkehub/multiclusteringress/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1beta/MANIFEST.in b/owl-bot-staging/v1beta/MANIFEST.in new file mode 100644 index 0000000..c6cdb90 --- /dev/null +++ b/owl-bot-staging/v1beta/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/gkehub/multiclusteringress *.py +recursive-include google/cloud/gkehub/multiclusteringress_v1beta *.py diff --git a/owl-bot-staging/v1beta/README.rst b/owl-bot-staging/v1beta/README.rst new file mode 100644 index 0000000..a4586cc --- /dev/null +++ b/owl-bot-staging/v1beta/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Gkehub Multiclusteringress API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Gkehub Multiclusteringress API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta/docs/conf.py b/owl-bot-staging/v1beta/docs/conf.py new file mode 100644 index 0000000..03b3c7b --- /dev/null +++ b/owl-bot-staging/v1beta/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# +# google-cloud-gkehub-multiclusteringress documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-gkehub-multiclusteringress" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Gkehub Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-gkehub-multiclusteringress-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress.tex", + u"google-cloud-gkehub-multiclusteringress Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress", + u"Google Cloud Gkehub Multiclusteringress Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-gkehub-multiclusteringress", + u"google-cloud-gkehub-multiclusteringress Documentation", + author, + "google-cloud-gkehub-multiclusteringress", + "GAPIC library for Google Cloud Gkehub Multiclusteringress API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst b/owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst new file mode 100644 index 0000000..1fde4d2 --- /dev/null +++ b/owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Configmanagement v1beta API +============================================================ +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst b/owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst new file mode 100644 index 0000000..a16ad45 --- /dev/null +++ b/owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Configmanagement v1beta API +========================================================= + +.. automodule:: google.cloud.gkehub.configmanagement_v1beta.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst b/owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst new file mode 100644 index 0000000..1a0098d --- /dev/null +++ b/owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst @@ -0,0 +1,10 @@ +GkeHub +------------------------ + +.. automodule:: google.cloud.gkehub_v1beta.services.gke_hub + :members: + :inherited-members: + +.. automodule:: google.cloud.gkehub_v1beta.services.gke_hub.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst b/owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst new file mode 100644 index 0000000..e2c6c8b --- /dev/null +++ b/owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Gkehub v1beta API +=========================================== +.. toctree:: + :maxdepth: 2 + + gke_hub diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst b/owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst new file mode 100644 index 0000000..35ca39f --- /dev/null +++ b/owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub v1beta API +======================================== + +.. automodule:: google.cloud.gkehub_v1beta.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta/docs/index.rst b/owl-bot-staging/v1beta/docs/index.rst new file mode 100644 index 0000000..814ab4a --- /dev/null +++ b/owl-bot-staging/v1beta/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + multiclusteringress_v1beta/services + multiclusteringress_v1beta/types diff --git a/owl-bot-staging/v1beta/docs/metering_v1beta/services.rst b/owl-bot-staging/v1beta/docs/metering_v1beta/services.rst new file mode 100644 index 0000000..9067958 --- /dev/null +++ b/owl-bot-staging/v1beta/docs/metering_v1beta/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Metering v1beta API +==================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1beta/docs/metering_v1beta/types.rst b/owl-bot-staging/v1beta/docs/metering_v1beta/types.rst new file mode 100644 index 0000000..c417a12 --- /dev/null +++ b/owl-bot-staging/v1beta/docs/metering_v1beta/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Metering v1beta API +================================================= + +.. automodule:: google.cloud.gkehub.metering_v1beta.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst b/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst new file mode 100644 index 0000000..01f8288 --- /dev/null +++ b/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst @@ -0,0 +1,4 @@ +Services for Google Cloud Gkehub Multiclusteringress v1beta API +=============================================================== +.. toctree:: + :maxdepth: 2 diff --git a/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst b/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst new file mode 100644 index 0000000..b3000cb --- /dev/null +++ b/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub Multiclusteringress v1beta API +============================================================ + +.. automodule:: google.cloud.gkehub.multiclusteringress_v1beta.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py new file mode 100644 index 0000000..04391d2 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub_v1beta.services.gke_hub.client import GkeHubClient +from google.cloud.gkehub_v1beta.services.gke_hub.async_client import GkeHubAsyncClient + +from google.cloud.gkehub_v1beta.types.feature import CommonFeatureSpec +from google.cloud.gkehub_v1beta.types.feature import CommonFeatureState +from google.cloud.gkehub_v1beta.types.feature import Feature +from google.cloud.gkehub_v1beta.types.feature import FeatureResourceState +from google.cloud.gkehub_v1beta.types.feature import FeatureState +from google.cloud.gkehub_v1beta.types.feature import MembershipFeatureSpec +from google.cloud.gkehub_v1beta.types.feature import MembershipFeatureState +from google.cloud.gkehub_v1beta.types.service import CreateFeatureRequest +from google.cloud.gkehub_v1beta.types.service import DeleteFeatureRequest +from google.cloud.gkehub_v1beta.types.service import GetFeatureRequest +from google.cloud.gkehub_v1beta.types.service import ListFeaturesRequest +from google.cloud.gkehub_v1beta.types.service import ListFeaturesResponse +from google.cloud.gkehub_v1beta.types.service import OperationMetadata +from google.cloud.gkehub_v1beta.types.service import UpdateFeatureRequest + +__all__ = ('GkeHubClient', + 'GkeHubAsyncClient', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'GetFeatureRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'OperationMetadata', + 'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py new file mode 100644 index 0000000..f19d1b8 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzConfig +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzVersion +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSync +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncDeploymentState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncVersion +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ErrorResource +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GatekeeperDeploymentState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GitConfig +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GroupVersionKind +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerConfig +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerDeploymentState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerVersion +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import InstallError +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import MembershipSpec +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import MembershipState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import OperatorState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyController +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyControllerState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyControllerVersion +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncError +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import DeploymentState + +__all__ = ('BinauthzConfig', + 'BinauthzState', + 'BinauthzVersion', + 'ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py new file mode 100644 index 0000000..03dba4e --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.configmanagement import BinauthzConfig +from .types.configmanagement import BinauthzState +from .types.configmanagement import BinauthzVersion +from .types.configmanagement import ConfigSync +from .types.configmanagement import ConfigSyncDeploymentState +from .types.configmanagement import ConfigSyncState +from .types.configmanagement import ConfigSyncVersion +from .types.configmanagement import ErrorResource +from .types.configmanagement import GatekeeperDeploymentState +from .types.configmanagement import GitConfig +from .types.configmanagement import GroupVersionKind +from .types.configmanagement import HierarchyControllerConfig +from .types.configmanagement import HierarchyControllerDeploymentState +from .types.configmanagement import HierarchyControllerState +from .types.configmanagement import HierarchyControllerVersion +from .types.configmanagement import InstallError +from .types.configmanagement import MembershipSpec +from .types.configmanagement import MembershipState +from .types.configmanagement import OperatorState +from .types.configmanagement import PolicyController +from .types.configmanagement import PolicyControllerState +from .types.configmanagement import PolicyControllerVersion +from .types.configmanagement import SyncError +from .types.configmanagement import SyncState +from .types.configmanagement import DeploymentState + +__all__ = ( +'BinauthzConfig', +'BinauthzState', +'BinauthzVersion', +'ConfigSync', +'ConfigSyncDeploymentState', +'ConfigSyncState', +'ConfigSyncVersion', +'DeploymentState', +'ErrorResource', +'GatekeeperDeploymentState', +'GitConfig', +'GroupVersionKind', +'HierarchyControllerConfig', +'HierarchyControllerDeploymentState', +'HierarchyControllerState', +'HierarchyControllerVersion', +'InstallError', +'MembershipSpec', +'MembershipState', +'OperatorState', +'PolicyController', +'PolicyControllerState', +'PolicyControllerVersion', +'SyncError', +'SyncState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json new file mode 100644 index 0000000..f5251c4 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.configmanagement_v1beta", + "protoPackage": "google.cloud.gkehub.configmanagement.v1beta", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed new file mode 100644 index 0000000..5d21684 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py new file mode 100644 index 0000000..91fc337 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .configmanagement import ( + BinauthzConfig, + BinauthzState, + BinauthzVersion, + ConfigSync, + ConfigSyncDeploymentState, + ConfigSyncState, + ConfigSyncVersion, + ErrorResource, + GatekeeperDeploymentState, + GitConfig, + GroupVersionKind, + HierarchyControllerConfig, + HierarchyControllerDeploymentState, + HierarchyControllerState, + HierarchyControllerVersion, + InstallError, + MembershipSpec, + MembershipState, + OperatorState, + PolicyController, + PolicyControllerState, + PolicyControllerVersion, + SyncError, + SyncState, + DeploymentState, +) + +__all__ = ( + 'BinauthzConfig', + 'BinauthzState', + 'BinauthzVersion', + 'ConfigSync', + 'ConfigSyncDeploymentState', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ErrorResource', + 'GatekeeperDeploymentState', + 'GitConfig', + 'GroupVersionKind', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerState', + 'HierarchyControllerVersion', + 'InstallError', + 'MembershipSpec', + 'MembershipState', + 'OperatorState', + 'PolicyController', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'SyncError', + 'SyncState', + 'DeploymentState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py new file mode 100644 index 0000000..9ae11c3 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py @@ -0,0 +1,837 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.configmanagement.v1beta', + manifest={ + 'DeploymentState', + 'MembershipState', + 'MembershipSpec', + 'ConfigSync', + 'GitConfig', + 'PolicyController', + 'BinauthzConfig', + 'HierarchyControllerConfig', + 'HierarchyControllerDeploymentState', + 'HierarchyControllerVersion', + 'HierarchyControllerState', + 'OperatorState', + 'InstallError', + 'ConfigSyncState', + 'ConfigSyncVersion', + 'ConfigSyncDeploymentState', + 'SyncState', + 'SyncError', + 'ErrorResource', + 'GroupVersionKind', + 'PolicyControllerState', + 'PolicyControllerVersion', + 'BinauthzState', + 'BinauthzVersion', + 'GatekeeperDeploymentState', + }, +) + + +class DeploymentState(proto.Enum): + r"""Enum representing the state of an ACM's deployment on a + cluster + """ + DEPLOYMENT_STATE_UNSPECIFIED = 0 + NOT_INSTALLED = 1 + INSTALLED = 2 + ERROR = 3 + + +class MembershipState(proto.Message): + r"""**Anthos Config Management**: State for a single cluster. + Attributes: + cluster_name (str): + The user-defined name for the cluster used by + ClusterSelectors to group clusters together. This should + match Membership's membership_name, unless the user + installed ACM on the cluster manually prior to enabling the + ACM hub feature. Unique within a Anthos Config Management + installation. + membership_spec (google.cloud.gkehub.configmanagement_v1beta.types.MembershipSpec): + Membership configuration in the cluster. This + represents the actual state in the cluster, + while the MembershipSpec in the FeatureSpec + represents the intended state + operator_state (google.cloud.gkehub.configmanagement_v1beta.types.OperatorState): + Current install status of ACM's Operator + config_sync_state (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncState): + Current sync status + policy_controller_state (google.cloud.gkehub.configmanagement_v1beta.types.PolicyControllerState): + PolicyController status + binauthz_state (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzState): + Binauthz status + hierarchy_controller_state (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerState): + Hierarchy Controller status + """ + + cluster_name = proto.Field( + proto.STRING, + number=1, + ) + membership_spec = proto.Field( + proto.MESSAGE, + number=2, + message='MembershipSpec', + ) + operator_state = proto.Field( + proto.MESSAGE, + number=3, + message='OperatorState', + ) + config_sync_state = proto.Field( + proto.MESSAGE, + number=4, + message='ConfigSyncState', + ) + policy_controller_state = proto.Field( + proto.MESSAGE, + number=5, + message='PolicyControllerState', + ) + binauthz_state = proto.Field( + proto.MESSAGE, + number=6, + message='BinauthzState', + ) + hierarchy_controller_state = proto.Field( + proto.MESSAGE, + number=7, + message='HierarchyControllerState', + ) + + +class MembershipSpec(proto.Message): + r"""**Anthos Config Management**: Configuration for a single cluster. + Intended to parallel the ConfigManagement CR. + + Attributes: + config_sync (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSync): + Config Sync configuration for the cluster. + policy_controller (google.cloud.gkehub.configmanagement_v1beta.types.PolicyController): + Policy Controller configuration for the + cluster. + binauthz (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzConfig): + Binauthz conifguration for the cluster. + hierarchy_controller (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerConfig): + Hierarchy Controller configuration for the + cluster. + version (str): + Version of ACM installed. + """ + + config_sync = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSync', + ) + policy_controller = proto.Field( + proto.MESSAGE, + number=2, + message='PolicyController', + ) + binauthz = proto.Field( + proto.MESSAGE, + number=3, + message='BinauthzConfig', + ) + hierarchy_controller = proto.Field( + proto.MESSAGE, + number=4, + message='HierarchyControllerConfig', + ) + version = proto.Field( + proto.STRING, + number=10, + ) + + +class ConfigSync(proto.Message): + r"""Configuration for Config Sync + Attributes: + git (google.cloud.gkehub.configmanagement_v1beta.types.GitConfig): + Git repo configuration for the cluster. + source_format (str): + Specifies whether the Config Sync Repo is + in “hierarchical” or “unstructured” mode. + """ + + git = proto.Field( + proto.MESSAGE, + number=7, + message='GitConfig', + ) + source_format = proto.Field( + proto.STRING, + number=8, + ) + + +class GitConfig(proto.Message): + r"""Git repo configuration for a single cluster. + Attributes: + sync_repo (str): + The URL of the Git repository to use as the + source of truth. + sync_branch (str): + The branch of the repository to sync from. + Default: master. + policy_dir (str): + The path within the Git repository that + represents the top level of the repo to sync. + Default: the root directory of the repository. + sync_wait_secs (int): + Period in seconds between consecutive syncs. + Default: 15. + sync_rev (str): + Git revision (tag or hash) to check out. + Default HEAD. + secret_type (str): + Type of secret configured for access to the + Git repo. + https_proxy (str): + URL for the HTTPS proxy to be used when + communicating with the Git repo. + gcp_service_account_email (str): + The GCP Service Account Email used for auth when secret_type + is gcpServiceAccount. + """ + + sync_repo = proto.Field( + proto.STRING, + number=1, + ) + sync_branch = proto.Field( + proto.STRING, + number=2, + ) + policy_dir = proto.Field( + proto.STRING, + number=3, + ) + sync_wait_secs = proto.Field( + proto.INT64, + number=4, + ) + sync_rev = proto.Field( + proto.STRING, + number=5, + ) + secret_type = proto.Field( + proto.STRING, + number=6, + ) + https_proxy = proto.Field( + proto.STRING, + number=7, + ) + gcp_service_account_email = proto.Field( + proto.STRING, + number=8, + ) + + +class PolicyController(proto.Message): + r"""Configuration for Policy Controller + Attributes: + enabled (bool): + Enables the installation of Policy + Controller. If false, the rest of + PolicyController fields take no effect. + template_library_installed (bool): + Installs the default template library along + with Policy Controller. + audit_interval_seconds (int): + Sets the interval for Policy Controller Audit + Scans (in seconds). When set to 0, this disables + audit functionality altogether. + exemptable_namespaces (Sequence[str]): + The set of namespaces that are excluded from + Policy Controller checks. Namespaces do not need + to currently exist on the cluster. + referential_rules_enabled (bool): + Enables the ability to use Constraint + Templates that reference to objects other than + the object currently being evaluated. + log_denies_enabled (bool): + Logs all denies and dry run failures. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + template_library_installed = proto.Field( + proto.BOOL, + number=2, + optional=True, + ) + audit_interval_seconds = proto.Field( + proto.INT64, + number=3, + optional=True, + ) + exemptable_namespaces = proto.RepeatedField( + proto.STRING, + number=4, + ) + referential_rules_enabled = proto.Field( + proto.BOOL, + number=5, + ) + log_denies_enabled = proto.Field( + proto.BOOL, + number=6, + ) + + +class BinauthzConfig(proto.Message): + r"""Configuration for Binauthz + Attributes: + enabled (bool): + Whether binauthz is enabled in this cluster. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + + +class HierarchyControllerConfig(proto.Message): + r"""Configuration for Hierarchy Controller + Attributes: + enabled (bool): + Whether Hierarchy Controller is enabled in + this cluster. + enable_pod_tree_labels (bool): + Whether pod tree labels are enabled in this + cluster. + enable_hierarchical_resource_quota (bool): + Whether hierarchical resource quota is + enabled in this cluster. + """ + + enabled = proto.Field( + proto.BOOL, + number=1, + ) + enable_pod_tree_labels = proto.Field( + proto.BOOL, + number=2, + ) + enable_hierarchical_resource_quota = proto.Field( + proto.BOOL, + number=3, + ) + + +class HierarchyControllerDeploymentState(proto.Message): + r"""Deployment state for Hierarchy Controller + Attributes: + hnc (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + The deployment state for open source HNC + (e.g. v0.7.0-hc.0) + extension (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + The deployment state for Hierarchy Controller + extension (e.g. v0.7.0-hc.1) + """ + + hnc = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + extension = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + + +class HierarchyControllerVersion(proto.Message): + r"""Version for Hierarchy Controller + Attributes: + hnc (str): + Version for open source HNC + extension (str): + Version for Hierarchy Controller extension + """ + + hnc = proto.Field( + proto.STRING, + number=1, + ) + extension = proto.Field( + proto.STRING, + number=2, + ) + + +class HierarchyControllerState(proto.Message): + r"""State for Hierarchy Controller + Attributes: + version (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerVersion): + The version for Hierarchy Controller + state (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerDeploymentState): + The deployment state for Hierarchy Controller + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='HierarchyControllerVersion', + ) + state = proto.Field( + proto.MESSAGE, + number=2, + message='HierarchyControllerDeploymentState', + ) + + +class OperatorState(proto.Message): + r"""State information for an ACM's Operator + Attributes: + version (str): + The semenatic version number of the operator + deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + The state of the Operator's deployment + errors (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.InstallError]): + Install errors. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + deployment_state = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='InstallError', + ) + + +class InstallError(proto.Message): + r"""Errors pertaining to the installation of ACM + Attributes: + error_message (str): + A string representing the user facing error + message + """ + + error_message = proto.Field( + proto.STRING, + number=1, + ) + + +class ConfigSyncState(proto.Message): + r"""State information for ConfigSync + Attributes: + version (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncVersion): + The version of ConfigSync deployed + deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncDeploymentState): + Information about the deployment of + ConfigSync, including the version of the various + Pods deployed + sync_state (google.cloud.gkehub.configmanagement_v1beta.types.SyncState): + The state of ConfigSync's process to sync + configs to a cluster + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='ConfigSyncVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='ConfigSyncDeploymentState', + ) + sync_state = proto.Field( + proto.MESSAGE, + number=3, + message='SyncState', + ) + + +class ConfigSyncVersion(proto.Message): + r"""Specific versioning information pertaining to ConfigSync's + Pods + + Attributes: + importer (str): + Version of the deployed importer pod + syncer (str): + Version of the deployed syncer pod + git_sync (str): + Version of the deployed git-sync pod + monitor (str): + Version of the deployed monitor pod + reconciler_manager (str): + Version of the deployed reconciler-manager + pod + root_reconciler (str): + Version of the deployed reconciler container + in root-reconciler pod + """ + + importer = proto.Field( + proto.STRING, + number=1, + ) + syncer = proto.Field( + proto.STRING, + number=2, + ) + git_sync = proto.Field( + proto.STRING, + number=3, + ) + monitor = proto.Field( + proto.STRING, + number=4, + ) + reconciler_manager = proto.Field( + proto.STRING, + number=5, + ) + root_reconciler = proto.Field( + proto.STRING, + number=6, + ) + + +class ConfigSyncDeploymentState(proto.Message): + r"""The state of ConfigSync's deployment on a cluster + Attributes: + importer (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of the importer pod + syncer (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of the syncer pod + git_sync (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of the git-sync pod + monitor (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of the monitor pod + reconciler_manager (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of reconciler-manager pod + root_reconciler (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Deployment state of root-reconciler + """ + + importer = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + syncer = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + git_sync = proto.Field( + proto.ENUM, + number=3, + enum='DeploymentState', + ) + monitor = proto.Field( + proto.ENUM, + number=4, + enum='DeploymentState', + ) + reconciler_manager = proto.Field( + proto.ENUM, + number=5, + enum='DeploymentState', + ) + root_reconciler = proto.Field( + proto.ENUM, + number=6, + enum='DeploymentState', + ) + + +class SyncState(proto.Message): + r"""State indicating an ACM's progress syncing configurations to + a cluster + + Attributes: + source_token (str): + Token indicating the state of the repo. + import_token (str): + Token indicating the state of the importer. + sync_token (str): + Token indicating the state of the syncer. + last_sync (str): + Deprecated: use last_sync_time instead. Timestamp of when + ACM last successfully synced the repo The time format is + specified in https://golang.org/pkg/time/#Time.String + last_sync_time (google.protobuf.timestamp_pb2.Timestamp): + Timestamp type of when ACM last successfully + synced the repo + code (google.cloud.gkehub.configmanagement_v1beta.types.SyncState.SyncCode): + Sync status code + errors (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.SyncError]): + A list of errors resulting from problematic + configs. This list will be truncated after 100 + errors, although it is unlikely for that many + errors to simultaneously exist. + """ + class SyncCode(proto.Enum): + r"""An enum representing an ACM's status syncing configs to a + cluster + """ + SYNC_CODE_UNSPECIFIED = 0 + SYNCED = 1 + PENDING = 2 + ERROR = 3 + NOT_CONFIGURED = 4 + NOT_INSTALLED = 5 + UNAUTHORIZED = 6 + UNREACHABLE = 7 + + source_token = proto.Field( + proto.STRING, + number=1, + ) + import_token = proto.Field( + proto.STRING, + number=2, + ) + sync_token = proto.Field( + proto.STRING, + number=3, + ) + last_sync = proto.Field( + proto.STRING, + number=4, + ) + last_sync_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + code = proto.Field( + proto.ENUM, + number=5, + enum=SyncCode, + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=6, + message='SyncError', + ) + + +class SyncError(proto.Message): + r"""An ACM created error representing a problem syncing + configurations + + Attributes: + code (str): + An ACM defined error code + error_message (str): + A description of the error + error_resources (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.ErrorResource]): + A list of config(s) associated with the + error, if any + """ + + code = proto.Field( + proto.STRING, + number=1, + ) + error_message = proto.Field( + proto.STRING, + number=2, + ) + error_resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ErrorResource', + ) + + +class ErrorResource(proto.Message): + r"""Model for a config file in the git repo with an associated + Sync error + + Attributes: + source_path (str): + Path in the git repo of the erroneous config + resource_name (str): + Metadata name of the resource that is causing + an error + resource_namespace (str): + Namespace of the resource that is causing an + error + resource_gvk (google.cloud.gkehub.configmanagement_v1beta.types.GroupVersionKind): + Group/version/kind of the resource that is + causing an error + """ + + source_path = proto.Field( + proto.STRING, + number=1, + ) + resource_name = proto.Field( + proto.STRING, + number=2, + ) + resource_namespace = proto.Field( + proto.STRING, + number=3, + ) + resource_gvk = proto.Field( + proto.MESSAGE, + number=4, + message='GroupVersionKind', + ) + + +class GroupVersionKind(proto.Message): + r"""A Kubernetes object's GVK + Attributes: + group (str): + Kubernetes Group + version (str): + Kubernetes Version + kind (str): + Kubernetes Kind + """ + + group = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + kind = proto.Field( + proto.STRING, + number=3, + ) + + +class PolicyControllerState(proto.Message): + r"""State for PolicyControllerState. + Attributes: + version (google.cloud.gkehub.configmanagement_v1beta.types.PolicyControllerVersion): + The version of Gatekeeper Policy Controller + deployed. + deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.GatekeeperDeploymentState): + The state about the policy controller + installation. + """ + + version = proto.Field( + proto.MESSAGE, + number=1, + message='PolicyControllerVersion', + ) + deployment_state = proto.Field( + proto.MESSAGE, + number=2, + message='GatekeeperDeploymentState', + ) + + +class PolicyControllerVersion(proto.Message): + r"""The build version of Gatekeeper Policy Controller is using. + Attributes: + version (str): + The gatekeeper image tag that is composed of + ACM version, git tag, build number. + """ + + version = proto.Field( + proto.STRING, + number=1, + ) + + +class BinauthzState(proto.Message): + r"""State for Binauthz + Attributes: + webhook (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + The state of the binauthz webhook. + version (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzVersion): + The version of binauthz that is installed. + """ + + webhook = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + version = proto.Field( + proto.MESSAGE, + number=2, + message='BinauthzVersion', + ) + + +class BinauthzVersion(proto.Message): + r"""The version of binauthz. + Attributes: + webhook_version (str): + The version of the binauthz webhook. + """ + + webhook_version = proto.Field( + proto.STRING, + number=1, + ) + + +class GatekeeperDeploymentState(proto.Message): + r"""State of Policy Controller installation. + Attributes: + gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Status of gatekeeper-controller-manager pod. + gatekeeper_audit (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): + Status of gatekeeper-audit deployment. + """ + + gatekeeper_controller_manager_state = proto.Field( + proto.ENUM, + number=1, + enum='DeploymentState', + ) + gatekeeper_audit = proto.Field( + proto.ENUM, + number=2, + enum='DeploymentState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py new file mode 100644 index 0000000..faffa99 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.metering_v1beta.types.metering import MembershipState + +__all__ = ('MembershipState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed new file mode 100644 index 0000000..1947b3f --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-metering package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py new file mode 100644 index 0000000..fe15d24 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.metering import MembershipState + +__all__ = ( +'MembershipState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json new file mode 100644 index 0000000..f6aa344 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.metering_v1beta", + "protoPackage": "google.cloud.gkehub.metering.v1beta", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed new file mode 100644 index 0000000..1947b3f --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-metering package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py new file mode 100644 index 0000000..9a626f7 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .metering import ( + MembershipState, +) + +__all__ = ( + 'MembershipState', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py new file mode 100644 index 0000000..d7cf3d5 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.metering.v1beta', + manifest={ + 'MembershipState', + }, +) + + +class MembershipState(proto.Message): + r"""**Metering**: Per-Membership Feature State. + Attributes: + last_measurement_time (google.protobuf.timestamp_pb2.Timestamp): + The time stamp of the most recent measurement + of the number of vCPUs in the cluster. + precise_last_measured_cluster_vcpu_capacity (float): + The vCPUs capacity in the cluster according + to the most recent measurement (1/1000 + precision). + """ + + last_measurement_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + precise_last_measured_cluster_vcpu_capacity = proto.Field( + proto.FLOAT, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py new file mode 100644 index 0000000..83bd925 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import FeatureSpec +from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import Billing + +__all__ = ('FeatureSpec', + 'Billing', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py new file mode 100644 index 0000000..a8fd7c2 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .types.multiclusteringress import FeatureSpec +from .types.multiclusteringress import Billing + +__all__ = ( +'Billing', +'FeatureSpec', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json new file mode 100644 index 0000000..3b263e7 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub.multiclusteringress_v1beta", + "protoPackage": "google.cloud.gkehub.multiclusteringress.v1beta", + "schema": "1.0" +} diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed new file mode 100644 index 0000000..298daf2 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py new file mode 100644 index 0000000..28b5fac --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .multiclusteringress import ( + FeatureSpec, + Billing, +) + +__all__ = ( + 'FeatureSpec', + 'Billing', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py new file mode 100644 index 0000000..344df3c --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.multiclusteringress.v1beta', + manifest={ + 'Billing', + 'FeatureSpec', + }, +) + + +class Billing(proto.Enum): + r"""Billing identifies which billing structure the customer is + using. + """ + BILLING_UNSPECIFIED = 0 + PAY_AS_YOU_GO = 1 + ANTHOS_LICENSE = 2 + + +class FeatureSpec(proto.Message): + r"""**Multi-cluster Ingress**: The configuration for the + MultiClusterIngress feature. + + Attributes: + config_membership (str): + Fully-qualified Membership name which hosts the + MultiClusterIngress CRD. Example: + ``projects/foo-proj/locations/global/memberships/bar`` + billing (google.cloud.gkehub.multiclusteringress_v1beta.types.Billing): + Customer's billing structure + """ + + config_membership = proto.Field( + proto.STRING, + number=1, + ) + billing = proto.Field( + proto.ENUM, + number=2, + enum='Billing', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py new file mode 100644 index 0000000..fe33a01 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .services.gke_hub import GkeHubClient +from .services.gke_hub import GkeHubAsyncClient + +from .types.feature import CommonFeatureSpec +from .types.feature import CommonFeatureState +from .types.feature import Feature +from .types.feature import FeatureResourceState +from .types.feature import FeatureState +from .types.feature import MembershipFeatureSpec +from .types.feature import MembershipFeatureState +from .types.service import CreateFeatureRequest +from .types.service import DeleteFeatureRequest +from .types.service import GetFeatureRequest +from .types.service import ListFeaturesRequest +from .types.service import ListFeaturesResponse +from .types.service import OperationMetadata +from .types.service import UpdateFeatureRequest + +__all__ = ( + 'GkeHubAsyncClient', +'CommonFeatureSpec', +'CommonFeatureState', +'CreateFeatureRequest', +'DeleteFeatureRequest', +'Feature', +'FeatureResourceState', +'FeatureState', +'GetFeatureRequest', +'GkeHubClient', +'ListFeaturesRequest', +'ListFeaturesResponse', +'MembershipFeatureSpec', +'MembershipFeatureState', +'OperationMetadata', +'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json new file mode 100644 index 0000000..18bfdca --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json @@ -0,0 +1,73 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub_v1beta", + "protoPackage": "google.cloud.gkehub.v1beta", + "schema": "1.0", + "services": { + "GkeHub": { + "clients": { + "grpc": { + "libraryClient": "GkeHubClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + } + } + }, + "grpc-async": { + "libraryClient": "GkeHubAsyncClient", + "rpcs": { + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py new file mode 100644 index 0000000..7304648 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .client import GkeHubClient +from .async_client import GkeHubAsyncClient + +__all__ = ( + 'GkeHubClient', + 'GkeHubAsyncClient', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py new file mode 100644 index 0000000..e0ac435 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py @@ -0,0 +1,657 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1beta.services.gke_hub import pagers +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport +from .client import GkeHubClient + + +class GkeHubAsyncClient: + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1beta.Membership] + - [Feature][google.cloud.gkehub.v1beta.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + _client: GkeHubClient + + DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT + + feature_path = staticmethod(GkeHubClient.feature_path) + parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) + common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + common_folder_path = staticmethod(GkeHubClient.common_folder_path) + parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) + common_organization_path = staticmethod(GkeHubClient.common_organization_path) + parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + common_project_path = staticmethod(GkeHubClient.common_project_path) + parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) + common_location_path = staticmethod(GkeHubClient.common_location_path) + parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubAsyncClient: The constructed client. + """ + return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = GkeHubClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: + r"""Lists Features in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1beta.types.ListFeaturesRequest`): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (:class:`str`): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1beta.services.gke_hub.pagers.ListFeaturesAsyncPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest(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_features, + 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.ListFeaturesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (:class:`google.cloud.gkehub_v1beta.types.GetFeatureRequest`): + The request object. Request message for + `GkeHub.GetFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1beta.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetFeatureRequest(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_feature, + 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 create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds a new Feature. + + Args: + request (:class:`google.cloud.gkehub_v1beta.types.CreateFeatureRequest`): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (:class:`str`): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1beta.types.Feature`): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (:class:`str`): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Feature. + + Args: + request (:class:`google.cloud.gkehub_v1beta.types.DeleteFeatureRequest`): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteFeatureRequest(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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Feature. + + Args: + request (:class:`google.cloud.gkehub_v1beta.types.UpdateFeatureRequest`): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (:class:`str`): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1beta.types.Feature`): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Mask of fields to update. + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubAsyncClient", +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py new file mode 100644 index 0000000..a7cf014 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py @@ -0,0 +1,844 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1beta.services.gke_hub import pagers +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import GkeHubGrpcTransport +from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +class GkeHubClientMeta(type): + """Metaclass for the GkeHub client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] + _transport_registry["grpc"] = GkeHubGrpcTransport + _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[GkeHubTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class GkeHubClient(metaclass=GkeHubClientMeta): + """The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1beta.Membership] + - [Feature][google.cloud.gkehub.v1beta.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "gkehub.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def feature_path(project: str,location: str,feature: str,) -> str: + """Returns a fully-qualified feature string.""" + return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + + @staticmethod + def parse_feature_path(path: str) -> Dict[str,str]: + """Parses a feature path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?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, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + 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, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, GkeHubTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, GkeHubTransport): + # transport is a GkeHubTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def list_features(self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: + r"""Lists Features in a given project and location. + + Args: + request (google.cloud.gkehub_v1beta.types.ListFeaturesRequest): + The request object. Request message for + `GkeHub.ListFeatures` method. + parent (str): + The parent (project and location) where the Features + will be listed. Specified in the format + ``projects/*/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.gkehub_v1beta.services.gke_hub.pagers.ListFeaturesPager: + Response message for the GkeHub.ListFeatures method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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.ListFeaturesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListFeaturesRequest): + request = service.ListFeaturesRequest(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_features] + + # 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.ListFeaturesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_feature(self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: + r"""Gets details of a single Feature. + + Args: + request (google.cloud.gkehub_v1beta.types.GetFeatureRequest): + The request object. Request message for + `GkeHub.GetFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + + 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.gkehub_v1beta.types.Feature: + Feature represents the settings and + status of any Hub Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetFeatureRequest): + request = service.GetFeatureRequest(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_feature] + + # 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 create_feature(self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds a new Feature. + + Args: + request (google.cloud.gkehub_v1beta.types.CreateFeatureRequest): + The request object. Request message for the + `GkeHub.CreateFeature` method. + parent (str): + The parent (project and location) where the Feature will + be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1beta.types.Feature): + The Feature resource to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feature_id (str): + The ID of the feature to create. + This corresponds to the ``feature_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateFeatureRequest): + request = service.CreateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if feature_id is not None: + request.feature_id = feature_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_feature] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_feature(self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Feature. + + Args: + request (google.cloud.gkehub_v1beta.types.DeleteFeatureRequest): + The request object. Request message for + `GkeHub.DeleteFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteFeatureRequest): + request = service.DeleteFeatureRequest(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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_feature(self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Feature. + + Args: + request (google.cloud.gkehub_v1beta.types.UpdateFeatureRequest): + The request object. Request message for + `GkeHub.UpdateFeature` method. + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1beta.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. If + you specify the update_mask to be a special path "*", + fully replaces all user-modifiable fields to match + ``resource``. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta.types.Feature` + Feature represents the settings and status of any Hub + Feature. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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.UpdateFeatureRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateFeatureRequest): + request = service.UpdateFeatureRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_feature] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + feature.Feature, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubClient", +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py new file mode 100644 index 0000000..f86c6a1 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service + + +class ListFeaturesPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` + 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.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1beta.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1beta.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListFeaturesResponse]: + 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) -> Iterable[feature.Feature]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFeaturesAsyncPager: + """A pager for iterating through ``list_features`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFeatures`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` + 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.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + 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.gkehub_v1beta.types.ListFeaturesRequest): + The initial request object. + response (google.cloud.gkehub_v1beta.types.ListFeaturesResponse): + 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.ListFeaturesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListFeaturesResponse]: + 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) -> AsyncIterable[feature.Feature]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py new file mode 100644 index 0000000..29c1c45 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import GkeHubTransport +from .grpc import GkeHubGrpcTransport +from .grpc_asyncio import GkeHubGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] +_transport_registry['grpc'] = GkeHubGrpcTransport +_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport + +__all__ = ( + 'GkeHubTransport', + 'GkeHubGrpcTransport', + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py new file mode 100644 index 0000000..fabd558 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py @@ -0,0 +1,232 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-gke-hub', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class GkeHubTransport(abc.ABC): + """Abstract transport class for GkeHub.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'gkehub.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + 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' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_features: gapic_v1.method.wrap_method( + self.list_features, + default_timeout=None, + client_info=client_info, + ), + self.get_feature: gapic_v1.method.wrap_method( + self.get_feature, + default_timeout=None, + client_info=client_info, + ), + self.create_feature: gapic_v1.method.wrap_method( + self.create_feature, + default_timeout=None, + client_info=client_info, + ), + self.delete_feature: gapic_v1.method.wrap_method( + self.delete_feature, + default_timeout=None, + client_info=client_info, + ), + self.update_feature: gapic_v1.method.wrap_method( + self.update_feature, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Union[ + service.ListFeaturesResponse, + Awaitable[service.ListFeaturesResponse] + ]]: + raise NotImplementedError() + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Union[ + feature.Feature, + Awaitable[feature.Feature] + ]]: + raise NotImplementedError() + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'GkeHubTransport', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py new file mode 100644 index 0000000..7d0203a --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py @@ -0,0 +1,386 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO + + +class GkeHubGrpcTransport(GkeHubTransport): + """gRPC backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1beta.Membership] + - [Feature][google.cloud.gkehub.v1beta.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + service.ListFeaturesResponse]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + ~.ListFeaturesResponse]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + feature.Feature]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + ~.Feature]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + operations_pb2.Operation]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + +__all__ = ( + 'GkeHubGrpcTransport', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py new file mode 100644 index 0000000..d71e720 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py @@ -0,0 +1,390 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubTransport, DEFAULT_CLIENT_INFO +from .grpc import GkeHubGrpcTransport + + +class GkeHubGrpcAsyncIOTransport(GkeHubTransport): + """gRPC AsyncIO backend transport for GkeHub. + + The GKE Hub service handles the registration of many Kubernetes + clusters to Google Cloud, and the management of multi-cluster + features over those clusters. + + The GKE Hub service operates on the following resources: + + - [Membership][google.cloud.gkehub.v1beta.Membership] + - [Feature][google.cloud.gkehub.v1beta.Feature] + + GKE Hub is currently only available in the global region. + + **Membership management may be non-trivial:** it is recommended to + use one of the Google-provided client libraries or tools where + possible when working with Membership resources. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_features(self) -> Callable[ + [service.ListFeaturesRequest], + Awaitable[service.ListFeaturesResponse]]: + r"""Return a callable for the list features method over gRPC. + + Lists Features in a given project and location. + + Returns: + Callable[[~.ListFeaturesRequest], + Awaitable[~.ListFeaturesResponse]]: + 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_features' not in self._stubs: + self._stubs['list_features'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/ListFeatures', + request_serializer=service.ListFeaturesRequest.serialize, + response_deserializer=service.ListFeaturesResponse.deserialize, + ) + return self._stubs['list_features'] + + @property + def get_feature(self) -> Callable[ + [service.GetFeatureRequest], + Awaitable[feature.Feature]]: + r"""Return a callable for the get feature method over gRPC. + + Gets details of a single Feature. + + Returns: + Callable[[~.GetFeatureRequest], + Awaitable[~.Feature]]: + 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_feature' not in self._stubs: + self._stubs['get_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/GetFeature', + request_serializer=service.GetFeatureRequest.serialize, + response_deserializer=feature.Feature.deserialize, + ) + return self._stubs['get_feature'] + + @property + def create_feature(self) -> Callable[ + [service.CreateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create feature method over gRPC. + + Adds a new Feature. + + Returns: + Callable[[~.CreateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_feature' not in self._stubs: + self._stubs['create_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/CreateFeature', + request_serializer=service.CreateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_feature'] + + @property + def delete_feature(self) -> Callable[ + [service.DeleteFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete feature method over gRPC. + + Removes a Feature. + + Returns: + Callable[[~.DeleteFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_feature' not in self._stubs: + self._stubs['delete_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature', + request_serializer=service.DeleteFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_feature'] + + @property + def update_feature(self) -> Callable[ + [service.UpdateFeatureRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update feature method over gRPC. + + Updates an existing Feature. + + Returns: + Callable[[~.UpdateFeatureRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_feature' not in self._stubs: + self._stubs['update_feature'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature', + request_serializer=service.UpdateFeatureRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_feature'] + + +__all__ = ( + 'GkeHubGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py new file mode 100644 index 0000000..09483e1 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .feature import ( + CommonFeatureSpec, + CommonFeatureState, + Feature, + FeatureResourceState, + FeatureState, + MembershipFeatureSpec, + MembershipFeatureState, +) +from .service import ( + CreateFeatureRequest, + DeleteFeatureRequest, + GetFeatureRequest, + ListFeaturesRequest, + ListFeaturesResponse, + OperationMetadata, + UpdateFeatureRequest, +) + +__all__ = ( + 'CommonFeatureSpec', + 'CommonFeatureState', + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'GetFeatureRequest', + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'OperationMetadata', + 'UpdateFeatureRequest', +) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py new file mode 100644 index 0000000..df6cb21 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py @@ -0,0 +1,303 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub.configmanagement.v1beta import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.metering.v1beta import metering_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1beta import multiclusteringress_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1beta', + manifest={ + 'Feature', + 'FeatureResourceState', + 'FeatureState', + 'CommonFeatureSpec', + 'CommonFeatureState', + 'MembershipFeatureSpec', + 'MembershipFeatureState', + }, +) + + +class Feature(proto.Message): + r"""Feature represents the settings and status of any Hub + Feature. + + Attributes: + name (str): + Output only. The full, unique name of this Feature resource + in the format ``projects/*/locations/*/features/*``. + labels (Sequence[google.cloud.gkehub_v1beta.types.Feature.LabelsEntry]): + GCP labels for this Feature. + resource_state (google.cloud.gkehub_v1beta.types.FeatureResourceState): + Output only. State of the Feature resource + itself. + spec (google.cloud.gkehub_v1beta.types.CommonFeatureSpec): + Optional. Hub-wide Feature configuration. If + this Feature does not support any Hub-wide + configuration, this field may be unused. + membership_specs (Sequence[google.cloud.gkehub_v1beta.types.Feature.MembershipSpecsEntry]): + Optional. Membership-specific configuration + for this Feature. If this Feature does not + support any per-Membership configuration, this + field may be unused. + The keys indicate which Membership the + configuration is for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} WILL match the + Feature's project. + + {p} will always be returned as the project + number, but the project ID is also accepted + during input. If the same Membership is + specified in the map twice (using the project ID + form, and the project number form), exactly ONE + of the entries will be saved, with no guarantees + as to which. For this reason, it is recommended + the same format be used for all entries when + mutating a Feature. + state (google.cloud.gkehub_v1beta.types.CommonFeatureState): + Output only. The Hub-wide Feature state. + membership_states (Sequence[google.cloud.gkehub_v1beta.types.Feature.MembershipStatesEntry]): + Output only. Membership-specific Feature + status. If this Feature does report any per- + Membership status, this field may be unused. + The keys indicate which Membership the state is + for, in the form: + projects/{p}/locations/{l}/memberships/{m} + Where {p} is the project number, {l} is a valid + location and {m} is a valid Membership in this + project at that location. {p} MUST match the + Feature's project number. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + last updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Feature resource was + deleted. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + resource_state = proto.Field( + proto.MESSAGE, + number=3, + message='FeatureResourceState', + ) + spec = proto.Field( + proto.MESSAGE, + number=4, + message='CommonFeatureSpec', + ) + membership_specs = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=5, + message='MembershipFeatureSpec', + ) + state = proto.Field( + proto.MESSAGE, + number=6, + message='CommonFeatureState', + ) + membership_states = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=7, + message='MembershipFeatureState', + ) + create_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, + ) + + +class FeatureResourceState(proto.Message): + r"""FeatureResourceState describes the state of a Feature *resource* in + the GkeHub API. See ``FeatureState`` for the "running state" of the + Feature in the Hub and across Memberships. + + Attributes: + state (google.cloud.gkehub_v1beta.types.FeatureResourceState.State): + The current state of the Feature resource in + the Hub API. + """ + class State(proto.Enum): + r"""State describes the lifecycle status of a Feature.""" + STATE_UNSPECIFIED = 0 + ENABLING = 1 + ACTIVE = 2 + DISABLING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + + +class FeatureState(proto.Message): + r"""FeatureState describes the high-level state of a Feature. It + may be used to describe a Feature's state at the environ-level, + or per-membershop, depending on the context. + + Attributes: + code (google.cloud.gkehub_v1beta.types.FeatureState.Code): + The high-level, machine-readable status of + this Feature. + description (str): + A human-readable description of the current + status. + update_time (google.protobuf.timestamp_pb2.Timestamp): + The time this status and any related Feature- + pecific details were updated. + """ + class Code(proto.Enum): + r"""Code represents a machine-readable, high-level status of the + Feature. + """ + CODE_UNSPECIFIED = 0 + OK = 1 + WARNING = 2 + ERROR = 3 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + + +class CommonFeatureSpec(proto.Message): + r"""CommonFeatureSpec contains Hub-wide configuration information + Attributes: + multiclusteringress (google.cloud.gkehub.multiclusteringress.v1beta.multiclusteringress_pb2.FeatureSpec): + Multicluster Ingress-specific spec. + """ + + multiclusteringress = proto.Field( + proto.MESSAGE, + number=102, + oneof='feature_spec', + message=multiclusteringress_pb2.FeatureSpec, + ) + + +class CommonFeatureState(proto.Message): + r"""CommonFeatureState contains Hub-wide Feature status + information. + + Attributes: + state (google.cloud.gkehub_v1beta.types.FeatureState): + Output only. The "running state" of the + Feature in this Hub. + """ + + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +class MembershipFeatureSpec(proto.Message): + r"""MembershipFeatureSpec contains configuration information for + a single Membership. + + Attributes: + configmanagement (google.cloud.gkehub.configmanagement.v1beta.configmanagement_pb2.MembershipSpec): + Config Management-specific spec. + """ + + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_spec', + message=configmanagement_pb2.MembershipSpec, + ) + + +class MembershipFeatureState(proto.Message): + r"""MembershipFeatureState contains Feature status information + for a single Membership. + + Attributes: + metering (google.cloud.gkehub.metering.v1beta.metering_pb2.MembershipState): + Metering-specific spec. + configmanagement (google.cloud.gkehub.configmanagement.v1beta.configmanagement_pb2.MembershipState): + Config Management-specific state. + state (google.cloud.gkehub_v1beta.types.FeatureState): + The high-level state of this Feature for a + single membership. + """ + + metering = proto.Field( + proto.MESSAGE, + number=104, + oneof='feature_state', + message=metering_pb2.MembershipState, + ) + configmanagement = proto.Field( + proto.MESSAGE, + number=106, + oneof='feature_state', + message=configmanagement_pb2.MembershipState, + ) + state = proto.Field( + proto.MESSAGE, + number=1, + message='FeatureState', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py new file mode 100644 index 0000000..9b2bec9 --- /dev/null +++ b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py @@ -0,0 +1,351 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.cloud.gkehub_v1beta.types import feature +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1beta', + manifest={ + 'ListFeaturesRequest', + 'ListFeaturesResponse', + 'GetFeatureRequest', + 'CreateFeatureRequest', + 'DeleteFeatureRequest', + 'UpdateFeatureRequest', + 'OperationMetadata', + }, +) + + +class ListFeaturesRequest(proto.Message): + r"""Request message for ``GkeHub.ListFeatures`` method. + Attributes: + parent (str): + The parent (project and location) where the Features will be + listed. Specified in the format ``projects/*/locations/*``. + page_size (int): + When requesting a 'page' of resources, ``page_size`` + specifies number of resources to return. If unspecified or + set to 0, all resources will be returned. + page_token (str): + Token returned by previous call to ``ListFeatures`` which + specifies the position in the list from where to continue + listing the resources. + filter (str): + Lists Features that match the filter expression, following + the syntax outlined in https://google.aip.dev/160. + + Examples: + + - Feature with the name "servicemesh" in project + "foo-proj": + + name = + "projects/foo-proj/locations/global/features/servicemesh" + + - Features that have a label called ``foo``: + + labels.foo:\* + + - Features that have a label called ``foo`` whose value is + ``bar``: + + labels.foo = bar + order_by (str): + One or more fields to compare and use to sort + the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListFeaturesResponse(proto.Message): + r"""Response message for the ``GkeHub.ListFeatures`` method. + Attributes: + resources (Sequence[google.cloud.gkehub_v1beta.types.Feature]): + The list of matching Features + next_page_token (str): + A token to request the next page of resources from the + ``ListFeatures`` method. The value of an empty string means + that there are no more resources to return. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=feature.Feature, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.GetFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*`` + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateFeatureRequest(proto.Message): + r"""Request message for the ``GkeHub.CreateFeature`` method. + Attributes: + parent (str): + The parent (project and location) where the Feature will be + created. Specified in the format ``projects/*/locations/*``. + feature_id (str): + The ID of the feature to create. + resource (google.cloud.gkehub_v1beta.types.Feature): + The Feature resource to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + feature_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DeleteFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.DeleteFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + force (bool): + If set to true, the delete will ignore any outstanding + resources for this Feature (that is, + ``FeatureState.has_resources`` is set to true). These + resources will NOT be cleaned up or modified in any way. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + force = proto.Field( + proto.BOOL, + number=2, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateFeatureRequest(proto.Message): + r"""Request message for ``GkeHub.UpdateFeature`` method. + Attributes: + name (str): + The Feature resource name in the format + ``projects/*/locations/*/features/*``. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Mask of fields to update. + resource (google.cloud.gkehub_v1beta.types.Feature): + Only fields specified in update_mask are updated. If you + specify a field in the update_mask but don't specify its + value here that field will be deleted. If you are updating a + map field, set the value of a key to null or empty string to + delete the key from the map. It's not possible to update a + key's value to the empty string. If you specify the + update_mask to be a special path "*", fully replaces all + user-modifiable fields to match ``resource``. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message=feature.Feature, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_detail (str): + Output only. Human-readable status of the + operation, if any. + cancel_requested (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/mypy.ini b/owl-bot-staging/v1beta/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1beta/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1beta/noxfile.py b/owl-bot-staging/v1beta/noxfile.py new file mode 100644 index 0000000..7bcadea --- /dev/null +++ b/owl-bot-staging/v1beta/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/gkehub/multiclusteringress_v1beta/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py b/owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py new file mode 100644 index 0000000..b06f1d0 --- /dev/null +++ b/owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class configmanagementCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=configmanagementCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the configmanagement client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py b/owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py new file mode 100644 index 0000000..fadc530 --- /dev/null +++ b/owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py @@ -0,0 +1,180 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class gkehubCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_feature': ('parent', 'feature_id', 'resource', 'request_id', ), + 'delete_feature': ('name', 'force', 'request_id', ), + 'get_feature': ('name', ), + 'list_features': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_feature': ('name', 'update_mask', 'resource', 'request_id', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=gkehubCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the gkehub client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py b/owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py new file mode 100644 index 0000000..53d00e3 --- /dev/null +++ b/owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class meteringCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=meteringCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the metering client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py b/owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py new file mode 100644 index 0000000..e15ebbc --- /dev/null +++ b/owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py @@ -0,0 +1,175 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class multiclusteringressCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=multiclusteringressCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the multiclusteringress client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta/setup.py b/owl-bot-staging/v1beta/setup.py new file mode 100644 index 0000000..e2e8ad3 --- /dev/null +++ b/owl-bot-staging/v1beta/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-gkehub-multiclusteringress', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1beta/tests/__init__.py b/owl-bot-staging/v1beta/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/__init__.py b/owl-bot-staging/v1beta/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py b/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py new file mode 100644 index 0000000..25d6d66 --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py @@ -0,0 +1,2333 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +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 operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.gkehub.configmanagement.v1beta import configmanagement_pb2 # type: ignore +from google.cloud.gkehub.metering.v1beta import metering_pb2 # type: ignore +from google.cloud.gkehub.multiclusteringress.v1beta import multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub_v1beta.services.gke_hub import GkeHubAsyncClient +from google.cloud.gkehub_v1beta.services.gke_hub import GkeHubClient +from google.cloud.gkehub_v1beta.services.gke_hub import pagers +from google.cloud.gkehub_v1beta.services.gke_hub import transports +from google.cloud.gkehub_v1beta.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1beta.types import feature +from google.cloud.gkehub_v1beta.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert GkeHubClient._get_default_mtls_endpoint(None) is None + assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_service_account_always_use_jwt(client_class): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + +@pytest.mark.parametrize("client_class", [ + GkeHubClient, + GkeHubAsyncClient, +]) +def test_gke_hub_client_from_service_account_file(client_class): + 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") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_client_get_transport_class(): + transport = GkeHubClient.get_transport_class() + available_transports = [ + transports.GkeHubGrpcTransport, + ] + assert transport in available_transports + + transport = GkeHubClient.get_transport_class("grpc") + assert transport == transports.GkeHubGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +def test_gke_hub_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) +@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + 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) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_gke_hub_client_client_options_from_dict(): + with mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = GkeHubClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_features(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.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_features_from_dict(): + test_list_features(request_type=dict) + + +def test_list_features_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 = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + client.list_features() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + +@pytest.mark.asyncio +async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_features(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListFeaturesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeaturesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_features_async_from_dict(): + await test_list_features_async(request_type=dict) + + +def test_list_features_field_headers(): + client = GkeHubClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = service.ListFeaturesResponse() + client.list_features(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_features_field_headers_async(): + client = GkeHubAsyncClient( + 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.ListFeaturesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + await client.list_features(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_features_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_features_flattened_error(): + client = GkeHubClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_features_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListFeaturesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_features( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_features_flattened_error_async(): + client = GkeHubAsyncClient( + 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_features( + service.ListFeaturesRequest(), + parent='parent_value', + ) + + +def test_list_features_pager(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_features(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, feature.Feature) + for i in results) + +def test_list_features_pages(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = list(client.list_features(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_features_async_pager(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_features(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, feature.Feature) + for i in responses) + +@pytest.mark.asyncio +async def test_list_features_async_pages(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_features), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + feature.Feature(), + ], + next_page_token='abc', + ), + service.ListFeaturesResponse( + resources=[], + next_page_token='def', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + ], + next_page_token='ghi', + ), + service.ListFeaturesResponse( + resources=[ + feature.Feature(), + feature.Feature(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_features(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature( + name='name_value', + ) + response = client.get_feature(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.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +def test_get_feature_from_dict(): + test_get_feature(request_type=dict) + + +def test_get_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.get_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + +@pytest.mark.asyncio +async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( + name='name_value', + )) + response = await client.get_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, feature.Feature) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_async_from_dict(): + await test_get_feature_async(request_type=dict) + + +def test_get_feature_field_headers(): + client = GkeHubClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = feature.Feature() + client.get_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.GetFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + await client.get_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = feature.Feature() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.GetFeatureRequest(), + name='name_value', + ) + + +def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_feature(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.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_feature_from_dict(): + test_create_feature(request_type=dict) + + +def test_create_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.create_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + +@pytest.mark.asyncio +async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_feature_async_from_dict(): + await test_create_feature_async(request_type=dict) + + +def test_create_feature_field_headers(): + client = GkeHubClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.CreateFeatureRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +def test_create_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_feature( + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].feature_id == 'feature_id_value' + + +@pytest.mark.asyncio +async def test_create_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.CreateFeatureRequest(), + parent='parent_value', + resource=feature.Feature(name='name_value'), + feature_id='feature_id_value', + ) + + +def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_feature(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.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_feature_from_dict(): + test_delete_feature(request_type=dict) + + +def test_delete_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.delete_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + +@pytest.mark.asyncio +async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_feature_async_from_dict(): + await test_delete_feature_async(request_type=dict) + + +def test_delete_feature_field_headers(): + client = GkeHubClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_feature(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_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.DeleteFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_feature(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_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_feature( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.DeleteFeatureRequest(), + name='name_value', + ) + + +def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): + client = GkeHubClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_feature(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.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_feature_from_dict(): + test_update_feature(request_type=dict) + + +def test_update_feature_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 = GkeHubClient( + 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_feature), + '__call__') as call: + client.update_feature() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + +@pytest.mark.asyncio +async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): + client = GkeHubAsyncClient( + 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_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_feature(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateFeatureRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_feature_async_from_dict(): + await test_update_feature_async(request_type=dict) + + +def test_update_feature_field_headers(): + client = GkeHubClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_feature(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_update_feature_field_headers_async(): + client = GkeHubAsyncClient( + 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.UpdateFeatureRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_feature(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_update_feature_flattened(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_feature_flattened_error(): + client = GkeHubClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_async(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feature), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_feature( + name='name_value', + resource=feature.Feature(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] + assert args[0].name == 'name_value' + assert args[0].resource == feature.Feature(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_feature_flattened_error_async(): + client = GkeHubAsyncClient( + 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_feature( + service.UpdateFeatureRequest(), + name='name_value', + resource=feature.Feature(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.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = GkeHubClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.GkeHubGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, +]) +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() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.GkeHubGrpcTransport, + ) + +def test_gke_hub_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_gke_hub_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.GkeHubTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_features', + 'get_feature', + 'create_feature', + 'delete_feature', + 'update_feature', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_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('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): + # 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('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_gke_hub_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_gke_hub_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubGrpcTransport, + transports.GkeHubGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.GkeHubGrpcTransport, grpc_helpers), + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "gkehub.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="gkehub.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_gke_hub_host_no_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + ) + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_host_with_port(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + ) + assert client.transport._host == 'gkehub.googleapis.com:8000' + +def test_gke_hub_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_gke_hub_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) +def test_gke_hub_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_gke_hub_grpc_lro_client(): + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_gke_hub_grpc_lro_async_client(): + client = GkeHubAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_feature_path(): + project = "squid" + location = "clam" + feature = "whelk" + expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + actual = GkeHubClient.feature_path(project, location, feature) + assert expected == actual + + +def test_parse_feature_path(): + expected = { + "project": "octopus", + "location": "oyster", + "feature": "nudibranch", + } + path = GkeHubClient.feature_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_feature_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = GkeHubClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = GkeHubClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = GkeHubClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = GkeHubClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = GkeHubClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = GkeHubClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = GkeHubClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = GkeHubClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = GkeHubClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = GkeHubClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + client = GkeHubClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + transport_class = GkeHubClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/.coveragerc b/owl-bot-staging/v1beta1/.coveragerc new file mode 100644 index 0000000..2b3ad0f --- /dev/null +++ b/owl-bot-staging/v1beta1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/gkehub/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1beta1/MANIFEST.in b/owl-bot-staging/v1beta1/MANIFEST.in new file mode 100644 index 0000000..5a63cc9 --- /dev/null +++ b/owl-bot-staging/v1beta1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/gkehub *.py +recursive-include google/cloud/gkehub_v1beta1 *.py diff --git a/owl-bot-staging/v1beta1/README.rst b/owl-bot-staging/v1beta1/README.rst new file mode 100644 index 0000000..00b883a --- /dev/null +++ b/owl-bot-staging/v1beta1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Gkehub API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Gkehub API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta1/docs/conf.py b/owl-bot-staging/v1beta1/docs/conf.py new file mode 100644 index 0000000..2e842ec --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# +# google-cloud-gke-hub documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-gke-hub" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-gke-hub-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-gke-hub.tex", + u"google-cloud-gke-hub Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-gke-hub", + u"Google Cloud Gkehub Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-gke-hub", + u"google-cloud-gke-hub Documentation", + author, + "google-cloud-gke-hub", + "GAPIC library for Google Cloud Gkehub API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst new file mode 100644 index 0000000..d234533 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst @@ -0,0 +1,10 @@ +GkeHubMembershipService +----------------------------------------- + +.. automodule:: google.cloud.gkehub_v1beta1.services.gke_hub_membership_service + :members: + :inherited-members: + +.. automodule:: google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst new file mode 100644 index 0000000..5ebd7a6 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Gkehub v1beta1 API +============================================ +.. toctree:: + :maxdepth: 2 + + gke_hub_membership_service diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst new file mode 100644 index 0000000..1f1cb49 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Gkehub v1beta1 API +========================================= + +.. automodule:: google.cloud.gkehub_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta1/docs/index.rst b/owl-bot-staging/v1beta1/docs/index.rst new file mode 100644 index 0000000..c840d89 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + gkehub_v1beta1/services + gkehub_v1beta1/types diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py new file mode 100644 index 0000000..8c1271f --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.client import GkeHubMembershipServiceClient +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.async_client import GkeHubMembershipServiceAsyncClient + +from google.cloud.gkehub_v1beta1.types.membership import Authority +from google.cloud.gkehub_v1beta1.types.membership import ConnectAgent +from google.cloud.gkehub_v1beta1.types.membership import ConnectAgentResource +from google.cloud.gkehub_v1beta1.types.membership import CreateMembershipRequest +from google.cloud.gkehub_v1beta1.types.membership import DeleteMembershipRequest +from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestRequest +from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestResponse +from google.cloud.gkehub_v1beta1.types.membership import GenerateExclusivityManifestRequest +from google.cloud.gkehub_v1beta1.types.membership import GenerateExclusivityManifestResponse +from google.cloud.gkehub_v1beta1.types.membership import GetMembershipRequest +from google.cloud.gkehub_v1beta1.types.membership import GkeCluster +from google.cloud.gkehub_v1beta1.types.membership import KubernetesMetadata +from google.cloud.gkehub_v1beta1.types.membership import KubernetesResource +from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsRequest +from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsResponse +from google.cloud.gkehub_v1beta1.types.membership import Membership +from google.cloud.gkehub_v1beta1.types.membership import MembershipEndpoint +from google.cloud.gkehub_v1beta1.types.membership import MembershipState +from google.cloud.gkehub_v1beta1.types.membership import OperationMetadata +from google.cloud.gkehub_v1beta1.types.membership import ResourceManifest +from google.cloud.gkehub_v1beta1.types.membership import ResourceOptions +from google.cloud.gkehub_v1beta1.types.membership import TypeMeta +from google.cloud.gkehub_v1beta1.types.membership import UpdateMembershipRequest +from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityRequest +from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityResponse + +__all__ = ('GkeHubMembershipServiceClient', + 'GkeHubMembershipServiceAsyncClient', + 'Authority', + 'ConnectAgent', + 'ConnectAgentResource', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GenerateExclusivityManifestRequest', + 'GenerateExclusivityManifestResponse', + 'GetMembershipRequest', + 'GkeCluster', + 'KubernetesMetadata', + 'KubernetesResource', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'OperationMetadata', + 'ResourceManifest', + 'ResourceOptions', + 'TypeMeta', + 'UpdateMembershipRequest', + 'ValidateExclusivityRequest', + 'ValidateExclusivityResponse', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed b/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py new file mode 100644 index 0000000..056d84e --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .services.gke_hub_membership_service import GkeHubMembershipServiceClient +from .services.gke_hub_membership_service import GkeHubMembershipServiceAsyncClient + +from .types.membership import Authority +from .types.membership import ConnectAgent +from .types.membership import ConnectAgentResource +from .types.membership import CreateMembershipRequest +from .types.membership import DeleteMembershipRequest +from .types.membership import GenerateConnectManifestRequest +from .types.membership import GenerateConnectManifestResponse +from .types.membership import GenerateExclusivityManifestRequest +from .types.membership import GenerateExclusivityManifestResponse +from .types.membership import GetMembershipRequest +from .types.membership import GkeCluster +from .types.membership import KubernetesMetadata +from .types.membership import KubernetesResource +from .types.membership import ListMembershipsRequest +from .types.membership import ListMembershipsResponse +from .types.membership import Membership +from .types.membership import MembershipEndpoint +from .types.membership import MembershipState +from .types.membership import OperationMetadata +from .types.membership import ResourceManifest +from .types.membership import ResourceOptions +from .types.membership import TypeMeta +from .types.membership import UpdateMembershipRequest +from .types.membership import ValidateExclusivityRequest +from .types.membership import ValidateExclusivityResponse + +__all__ = ( + 'GkeHubMembershipServiceAsyncClient', +'Authority', +'ConnectAgent', +'ConnectAgentResource', +'CreateMembershipRequest', +'DeleteMembershipRequest', +'GenerateConnectManifestRequest', +'GenerateConnectManifestResponse', +'GenerateExclusivityManifestRequest', +'GenerateExclusivityManifestResponse', +'GetMembershipRequest', +'GkeCluster', +'GkeHubMembershipServiceClient', +'KubernetesMetadata', +'KubernetesResource', +'ListMembershipsRequest', +'ListMembershipsResponse', +'Membership', +'MembershipEndpoint', +'MembershipState', +'OperationMetadata', +'ResourceManifest', +'ResourceOptions', +'TypeMeta', +'UpdateMembershipRequest', +'ValidateExclusivityRequest', +'ValidateExclusivityResponse', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json new file mode 100644 index 0000000..9f0aee4 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json @@ -0,0 +1,103 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.gkehub_v1beta1", + "protoPackage": "google.cloud.gkehub.v1beta1", + "schema": "1.0", + "services": { + "GkeHubMembershipService": { + "clients": { + "grpc": { + "libraryClient": "GkeHubMembershipServiceClient", + "rpcs": { + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GenerateExclusivityManifest": { + "methods": [ + "generate_exclusivity_manifest" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + }, + "ValidateExclusivity": { + "methods": [ + "validate_exclusivity" + ] + } + } + }, + "grpc-async": { + "libraryClient": "GkeHubMembershipServiceAsyncClient", + "rpcs": { + "CreateMembership": { + "methods": [ + "create_membership" + ] + }, + "DeleteMembership": { + "methods": [ + "delete_membership" + ] + }, + "GenerateConnectManifest": { + "methods": [ + "generate_connect_manifest" + ] + }, + "GenerateExclusivityManifest": { + "methods": [ + "generate_exclusivity_manifest" + ] + }, + "GetMembership": { + "methods": [ + "get_membership" + ] + }, + "ListMemberships": { + "methods": [ + "list_memberships" + ] + }, + "UpdateMembership": { + "methods": [ + "update_membership" + ] + }, + "ValidateExclusivity": { + "methods": [ + "validate_exclusivity" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed new file mode 100644 index 0000000..7a6a6d0 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py new file mode 100644 index 0000000..4b66850 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .client import GkeHubMembershipServiceClient +from .async_client import GkeHubMembershipServiceAsyncClient + +__all__ = ( + 'GkeHubMembershipServiceClient', + 'GkeHubMembershipServiceAsyncClient', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py new file mode 100644 index 0000000..689b04c --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py @@ -0,0 +1,842 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers +from google.cloud.gkehub_v1beta1.types import membership +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from .transports.base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport +from .client import GkeHubMembershipServiceClient + + +class GkeHubMembershipServiceAsyncClient: + """GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + """ + + _client: GkeHubMembershipServiceClient + + DEFAULT_ENDPOINT = GkeHubMembershipServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = GkeHubMembershipServiceClient.DEFAULT_MTLS_ENDPOINT + + membership_path = staticmethod(GkeHubMembershipServiceClient.membership_path) + parse_membership_path = staticmethod(GkeHubMembershipServiceClient.parse_membership_path) + common_billing_account_path = staticmethod(GkeHubMembershipServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(GkeHubMembershipServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(GkeHubMembershipServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(GkeHubMembershipServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(GkeHubMembershipServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(GkeHubMembershipServiceClient.parse_common_organization_path) + common_project_path = staticmethod(GkeHubMembershipServiceClient.common_project_path) + parse_common_project_path = staticmethod(GkeHubMembershipServiceClient.parse_common_project_path) + common_location_path = staticmethod(GkeHubMembershipServiceClient.common_location_path) + parse_common_location_path = staticmethod(GkeHubMembershipServiceClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubMembershipServiceAsyncClient: The constructed client. + """ + return GkeHubMembershipServiceClient.from_service_account_info.__func__(GkeHubMembershipServiceAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubMembershipServiceAsyncClient: The constructed client. + """ + return GkeHubMembershipServiceClient.from_service_account_file.__func__(GkeHubMembershipServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubMembershipServiceTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubMembershipServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(GkeHubMembershipServiceClient).get_transport_class, type(GkeHubMembershipServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubMembershipServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub membership service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.GkeHubMembershipServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = GkeHubMembershipServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_memberships(self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsAsyncPager: + r"""Lists Memberships in a given project and location. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.ListMembershipsRequest`): + The request object. Request message for + `GkeHubMembershipService.ListMemberships` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1beta1.services.gke_hub_membership_service.pagers.ListMembershipsAsyncPager: + Response message for the + GkeHubMembershipService.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 = membership.ListMembershipsRequest(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_memberships, + 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.ListMembershipsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_membership(self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.GetMembershipRequest`): + The request object. Request message for + `GkeHubMembershipService.GetMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1beta1.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = membership.GetMembershipRequest(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_membership, + 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 create_membership(self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds a new Membership. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.CreateMembershipRequest`): + The request object. Request message for the + `GkeHubMembershipService.CreateMembership` method. + parent (:class:`str`): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1beta1.types.Membership`): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (:class:`str`): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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 = membership.CreateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_membership(self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Removes a Membership. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.DeleteMembershipRequest`): + The request object. Request message for + `GkeHubMembershipService.DeleteMembership` method. + name (:class:`str`): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = membership.DeleteMembershipRequest(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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_membership(self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates an existing Membership. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.UpdateMembershipRequest`): + The request object. Request message for + `GkeHubMembershipService.UpdateMembership` method. + name (:class:`str`): + Required. The membership resource name in the format: + ``projects/[project_id]/locations/global/memberships/[membership_id]`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.gkehub_v1beta1.types.Membership`): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Mask of fields to update. + At least one field path must be + specified in this mask. + + 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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 = membership.UpdateMembershipRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + async def generate_connect_manifest(self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE + connect agent. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.GenerateConnectManifestRequest`): + The request object. Request message for + `GkeHubMembershipService.GenerateConnectManifest` + method. . + 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.gkehub_v1beta1.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + request = membership.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.generate_connect_manifest, + 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 validate_exclusivity(self, + request: membership.ValidateExclusivityRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.ValidateExclusivityResponse: + r"""ValidateExclusivity validates the state of + exclusivity in the cluster. The validation does not + depend on an existing Hub membership resource. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.ValidateExclusivityRequest`): + The request object. The request to validate the existing + state of the membership CR in the cluster. + 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.gkehub_v1beta1.types.ValidateExclusivityResponse: + The response of exclusivity artifacts + validation result status. + + """ + # Create or coerce a protobuf request object. + request = membership.ValidateExclusivityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.validate_exclusivity, + 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 generate_exclusivity_manifest(self, + request: membership.GenerateExclusivityManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateExclusivityManifestResponse: + r"""GenerateExclusivityManifest generates the manifests + to update the exclusivity artifacts in the cluster if + needed. + Exclusivity artifacts include the Membership custom + resource definition (CRD) and the singleton Membership + custom resource (CR). Combined with ValidateExclusivity, + exclusivity artifacts guarantee that a Kubernetes + cluster is only registered to a single GKE Hub. + + The Membership CRD is versioned, and may require + conversion when the GKE Hub API server begins serving a + newer version of the CRD and corresponding CR. The + response will be the converted CRD and CR if there are + any differences between the versions. + + Args: + request (:class:`google.cloud.gkehub_v1beta1.types.GenerateExclusivityManifestRequest`): + The request object. The request to generate the + manifests for exclusivity artifacts. + 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.gkehub_v1beta1.types.GenerateExclusivityManifestResponse: + The response of the exclusivity + artifacts manifests for the client to + apply. + + """ + # Create or coerce a protobuf request object. + request = membership.GenerateExclusivityManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.generate_exclusivity_manifest, + 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 + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubMembershipServiceAsyncClient", +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py new file mode 100644 index 0000000..2bd7ce0 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py @@ -0,0 +1,1032 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers +from google.cloud.gkehub_v1beta1.types import membership +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from .transports.base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import GkeHubMembershipServiceGrpcTransport +from .transports.grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport + + +class GkeHubMembershipServiceClientMeta(type): + """Metaclass for the GkeHubMembershipService client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubMembershipServiceTransport]] + _transport_registry["grpc"] = GkeHubMembershipServiceGrpcTransport + _transport_registry["grpc_asyncio"] = GkeHubMembershipServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[GkeHubMembershipServiceTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class GkeHubMembershipServiceClient(metaclass=GkeHubMembershipServiceClientMeta): + """GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "gkehub.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubMembershipServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + GkeHubMembershipServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> GkeHubMembershipServiceTransport: + """Returns the transport used by the client instance. + + Returns: + GkeHubMembershipServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def membership_path(project: str,location: str,membership: str,) -> str: + """Returns a fully-qualified membership string.""" + return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + + @staticmethod + def parse_membership_path(path: str) -> Dict[str,str]: + """Parses a membership path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?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, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + 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, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubMembershipServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the gke hub membership service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, GkeHubMembershipServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, GkeHubMembershipServiceTransport): + # transport is a GkeHubMembershipServiceTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def list_memberships(self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsPager: + r"""Lists Memberships in a given project and location. + + Args: + request (google.cloud.gkehub_v1beta1.types.ListMembershipsRequest): + The request object. Request message for + `GkeHubMembershipService.ListMemberships` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/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.gkehub_v1beta1.services.gke_hub_membership_service.pagers.ListMembershipsPager: + Response message for the + GkeHubMembershipService.ListMemberships method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 membership.ListMembershipsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.ListMembershipsRequest): + request = membership.ListMembershipsRequest(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_memberships] + + # 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.ListMembershipsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_membership(self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: + r"""Gets the details of a Membership. + + Args: + request (google.cloud.gkehub_v1beta1.types.GetMembershipRequest): + The request object. Request message for + `GkeHubMembershipService.GetMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + 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.gkehub_v1beta1.types.Membership: + Membership contains information about + a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a membership.GetMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.GetMembershipRequest): + request = membership.GetMembershipRequest(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_membership] + + # 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 create_membership(self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds a new Membership. + + Args: + request (google.cloud.gkehub_v1beta1.types.CreateMembershipRequest): + The request object. Request message for the + `GkeHubMembershipService.CreateMembership` method. + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1beta1.types.Membership): + Required. The membership to create. + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters + or ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length + of 63 characters. + + This corresponds to the ``membership_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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, resource, membership_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 membership.CreateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.CreateMembershipRequest): + request = membership.CreateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if resource is not None: + request.resource = resource + if membership_id is not None: + request.membership_id = membership_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_membership] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_membership(self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Removes a Membership. + + Args: + request (google.cloud.gkehub_v1beta1.types.DeleteMembershipRequest): + The request object. Request message for + `GkeHubMembershipService.DeleteMembership` method. + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a membership.DeleteMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.DeleteMembershipRequest): + request = membership.DeleteMembershipRequest(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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_membership(self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates an existing Membership. + + Args: + request (google.cloud.gkehub_v1beta1.types.UpdateMembershipRequest): + The request object. Request message for + `GkeHubMembershipService.UpdateMembership` method. + name (str): + Required. The membership resource name in the format: + ``projects/[project_id]/locations/global/memberships/[membership_id]`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.gkehub_v1beta1.types.Membership): + Required. Only fields specified in update_mask are + updated. If you specify a field in the update_mask but + don't specify its value here that field will be deleted. + If you are updating a map field, set the value of a key + to null or empty string to delete the key from the map. + It's not possible to update a key's value to the empty + string. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + At least one field path must be + specified in this mask. + + 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.gkehub_v1beta1.types.Membership` + Membership contains information about a member cluster. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, resource, 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 membership.UpdateMembershipRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.UpdateMembershipRequest): + request = membership.UpdateMembershipRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if resource is not None: + request.resource = resource + 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_membership] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + membership.Membership, + metadata_type=membership.OperationMetadata, + ) + + # Done; return the response. + return response + + def generate_connect_manifest(self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: + r"""Generates the manifest for deployment of the GKE + connect agent. + + Args: + request (google.cloud.gkehub_v1beta1.types.GenerateConnectManifestRequest): + The request object. Request message for + `GkeHubMembershipService.GenerateConnectManifest` + method. . + 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.gkehub_v1beta1.types.GenerateConnectManifestResponse: + GenerateConnectManifestResponse + contains manifest information for + installing/upgrading a Connect agent. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a membership.GenerateConnectManifestRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.GenerateConnectManifestRequest): + request = membership.GenerateConnectManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] + + # 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 validate_exclusivity(self, + request: membership.ValidateExclusivityRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.ValidateExclusivityResponse: + r"""ValidateExclusivity validates the state of + exclusivity in the cluster. The validation does not + depend on an existing Hub membership resource. + + Args: + request (google.cloud.gkehub_v1beta1.types.ValidateExclusivityRequest): + The request object. The request to validate the existing + state of the membership CR in the cluster. + 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.gkehub_v1beta1.types.ValidateExclusivityResponse: + The response of exclusivity artifacts + validation result status. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a membership.ValidateExclusivityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.ValidateExclusivityRequest): + request = membership.ValidateExclusivityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.validate_exclusivity] + + # 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 generate_exclusivity_manifest(self, + request: membership.GenerateExclusivityManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateExclusivityManifestResponse: + r"""GenerateExclusivityManifest generates the manifests + to update the exclusivity artifacts in the cluster if + needed. + Exclusivity artifacts include the Membership custom + resource definition (CRD) and the singleton Membership + custom resource (CR). Combined with ValidateExclusivity, + exclusivity artifacts guarantee that a Kubernetes + cluster is only registered to a single GKE Hub. + + The Membership CRD is versioned, and may require + conversion when the GKE Hub API server begins serving a + newer version of the CRD and corresponding CR. The + response will be the converted CRD and CR if there are + any differences between the versions. + + Args: + request (google.cloud.gkehub_v1beta1.types.GenerateExclusivityManifestRequest): + The request object. The request to generate the + manifests for exclusivity artifacts. + 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.gkehub_v1beta1.types.GenerateExclusivityManifestResponse: + The response of the exclusivity + artifacts manifests for the client to + apply. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a membership.GenerateExclusivityManifestRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, membership.GenerateExclusivityManifestRequest): + request = membership.GenerateExclusivityManifestRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.generate_exclusivity_manifest] + + # 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 + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-gke-hub", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "GkeHubMembershipServiceClient", +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py new file mode 100644 index 0000000..05472ae --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.gkehub_v1beta1.types import membership + + +class ListMembershipsPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` + 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[..., membership.ListMembershipsResponse], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + 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.gkehub_v1beta1.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1beta1.types.ListMembershipsResponse): + 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 = membership.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[membership.ListMembershipsResponse]: + 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) -> Iterable[membership.Membership]: + for page in self.pages: + yield from page.resources + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListMembershipsAsyncPager: + """A pager for iterating through ``list_memberships`` requests. + + This class thinly wraps an initial + :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``resources`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMemberships`` requests and continue to iterate + through the ``resources`` field on the + corresponding responses. + + All the usual :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` + 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[membership.ListMembershipsResponse]], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + 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.gkehub_v1beta1.types.ListMembershipsRequest): + The initial request object. + response (google.cloud.gkehub_v1beta1.types.ListMembershipsResponse): + 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 = membership.ListMembershipsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[membership.ListMembershipsResponse]: + 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) -> AsyncIterable[membership.Membership]: + async def async_generator(): + async for page in self.pages: + for response in page.resources: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py new file mode 100644 index 0000000..88ea247 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import GkeHubMembershipServiceTransport +from .grpc import GkeHubMembershipServiceGrpcTransport +from .grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubMembershipServiceTransport]] +_transport_registry['grpc'] = GkeHubMembershipServiceGrpcTransport +_transport_registry['grpc_asyncio'] = GkeHubMembershipServiceGrpcAsyncIOTransport + +__all__ = ( + 'GkeHubMembershipServiceTransport', + 'GkeHubMembershipServiceGrpcTransport', + 'GkeHubMembershipServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py new file mode 100644 index 0000000..189e6dd --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py @@ -0,0 +1,273 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.gkehub_v1beta1.types import membership +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-gke-hub', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class GkeHubMembershipServiceTransport(abc.ABC): + """Abstract transport class for GkeHubMembershipService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'gkehub.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + 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' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_memberships: gapic_v1.method.wrap_method( + self.list_memberships, + default_timeout=None, + client_info=client_info, + ), + self.get_membership: gapic_v1.method.wrap_method( + self.get_membership, + default_timeout=None, + client_info=client_info, + ), + self.create_membership: gapic_v1.method.wrap_method( + self.create_membership, + default_timeout=None, + client_info=client_info, + ), + self.delete_membership: gapic_v1.method.wrap_method( + self.delete_membership, + default_timeout=None, + client_info=client_info, + ), + self.update_membership: gapic_v1.method.wrap_method( + self.update_membership, + default_timeout=None, + client_info=client_info, + ), + self.generate_connect_manifest: gapic_v1.method.wrap_method( + self.generate_connect_manifest, + default_timeout=None, + client_info=client_info, + ), + self.validate_exclusivity: gapic_v1.method.wrap_method( + self.validate_exclusivity, + default_timeout=None, + client_info=client_info, + ), + self.generate_exclusivity_manifest: gapic_v1.method.wrap_method( + self.generate_exclusivity_manifest, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + Union[ + membership.ListMembershipsResponse, + Awaitable[membership.ListMembershipsResponse] + ]]: + raise NotImplementedError() + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + Union[ + membership.Membership, + Awaitable[membership.Membership] + ]]: + raise NotImplementedError() + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + Union[ + membership.GenerateConnectManifestResponse, + Awaitable[membership.GenerateConnectManifestResponse] + ]]: + raise NotImplementedError() + + @property + def validate_exclusivity(self) -> Callable[ + [membership.ValidateExclusivityRequest], + Union[ + membership.ValidateExclusivityResponse, + Awaitable[membership.ValidateExclusivityResponse] + ]]: + raise NotImplementedError() + + @property + def generate_exclusivity_manifest(self) -> Callable[ + [membership.GenerateExclusivityManifestRequest], + Union[ + membership.GenerateExclusivityManifestResponse, + Awaitable[membership.GenerateExclusivityManifestResponse] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'GkeHubMembershipServiceTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py new file mode 100644 index 0000000..c738350 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py @@ -0,0 +1,468 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.gkehub_v1beta1.types import membership +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO + + +class GkeHubMembershipServiceGrpcTransport(GkeHubMembershipServiceTransport): + """gRPC backend transport for GkeHubMembershipService. + + GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + membership.ListMembershipsResponse]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + ~.ListMembershipsResponse]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ListMemberships', + request_serializer=membership.ListMembershipsRequest.serialize, + response_deserializer=membership.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + membership.Membership]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + ~.Membership]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GetMembership', + request_serializer=membership.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the create membership method over gRPC. + + Adds a new Membership. + + Returns: + Callable[[~.CreateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/CreateMembership', + request_serializer=membership.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + Returns: + Callable[[~.DeleteMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/DeleteMembership', + request_serializer=membership.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + operations_pb2.Operation]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/UpdateMembership', + request_serializer=membership.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + membership.GenerateConnectManifestResponse]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE + connect agent. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + ~.GenerateConnectManifestResponse]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateConnectManifest', + request_serializer=membership.GenerateConnectManifestRequest.serialize, + response_deserializer=membership.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + @property + def validate_exclusivity(self) -> Callable[ + [membership.ValidateExclusivityRequest], + membership.ValidateExclusivityResponse]: + r"""Return a callable for the validate exclusivity method over gRPC. + + ValidateExclusivity validates the state of + exclusivity in the cluster. The validation does not + depend on an existing Hub membership resource. + + Returns: + Callable[[~.ValidateExclusivityRequest], + ~.ValidateExclusivityResponse]: + 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 'validate_exclusivity' not in self._stubs: + self._stubs['validate_exclusivity'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ValidateExclusivity', + request_serializer=membership.ValidateExclusivityRequest.serialize, + response_deserializer=membership.ValidateExclusivityResponse.deserialize, + ) + return self._stubs['validate_exclusivity'] + + @property + def generate_exclusivity_manifest(self) -> Callable[ + [membership.GenerateExclusivityManifestRequest], + membership.GenerateExclusivityManifestResponse]: + r"""Return a callable for the generate exclusivity manifest method over gRPC. + + GenerateExclusivityManifest generates the manifests + to update the exclusivity artifacts in the cluster if + needed. + Exclusivity artifacts include the Membership custom + resource definition (CRD) and the singleton Membership + custom resource (CR). Combined with ValidateExclusivity, + exclusivity artifacts guarantee that a Kubernetes + cluster is only registered to a single GKE Hub. + + The Membership CRD is versioned, and may require + conversion when the GKE Hub API server begins serving a + newer version of the CRD and corresponding CR. The + response will be the converted CRD and CR if there are + any differences between the versions. + + Returns: + Callable[[~.GenerateExclusivityManifestRequest], + ~.GenerateExclusivityManifestResponse]: + 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 'generate_exclusivity_manifest' not in self._stubs: + self._stubs['generate_exclusivity_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateExclusivityManifest', + request_serializer=membership.GenerateExclusivityManifestRequest.serialize, + response_deserializer=membership.GenerateExclusivityManifestResponse.deserialize, + ) + return self._stubs['generate_exclusivity_manifest'] + + +__all__ = ( + 'GkeHubMembershipServiceGrpcTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py new file mode 100644 index 0000000..dc75184 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py @@ -0,0 +1,472 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.gkehub_v1beta1.types import membership +from google.longrunning import operations_pb2 # type: ignore +from .base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import GkeHubMembershipServiceGrpcTransport + + +class GkeHubMembershipServiceGrpcAsyncIOTransport(GkeHubMembershipServiceTransport): + """gRPC AsyncIO backend transport for GkeHubMembershipService. + + GKE Hub CRUD API for the Membership resource. + The Membership service is currently only available in the global + location. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'gkehub.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_memberships(self) -> Callable[ + [membership.ListMembershipsRequest], + Awaitable[membership.ListMembershipsResponse]]: + r"""Return a callable for the list memberships method over gRPC. + + Lists Memberships in a given project and location. + + Returns: + Callable[[~.ListMembershipsRequest], + Awaitable[~.ListMembershipsResponse]]: + 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_memberships' not in self._stubs: + self._stubs['list_memberships'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ListMemberships', + request_serializer=membership.ListMembershipsRequest.serialize, + response_deserializer=membership.ListMembershipsResponse.deserialize, + ) + return self._stubs['list_memberships'] + + @property + def get_membership(self) -> Callable[ + [membership.GetMembershipRequest], + Awaitable[membership.Membership]]: + r"""Return a callable for the get membership method over gRPC. + + Gets the details of a Membership. + + Returns: + Callable[[~.GetMembershipRequest], + Awaitable[~.Membership]]: + 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_membership' not in self._stubs: + self._stubs['get_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GetMembership', + request_serializer=membership.GetMembershipRequest.serialize, + response_deserializer=membership.Membership.deserialize, + ) + return self._stubs['get_membership'] + + @property + def create_membership(self) -> Callable[ + [membership.CreateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create membership method over gRPC. + + Adds a new Membership. + + Returns: + Callable[[~.CreateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_membership' not in self._stubs: + self._stubs['create_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/CreateMembership', + request_serializer=membership.CreateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_membership'] + + @property + def delete_membership(self) -> Callable[ + [membership.DeleteMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete membership method over gRPC. + + Removes a Membership. + + Returns: + Callable[[~.DeleteMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_membership' not in self._stubs: + self._stubs['delete_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/DeleteMembership', + request_serializer=membership.DeleteMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_membership'] + + @property + def update_membership(self) -> Callable[ + [membership.UpdateMembershipRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update membership method over gRPC. + + Updates an existing Membership. + + Returns: + Callable[[~.UpdateMembershipRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_membership' not in self._stubs: + self._stubs['update_membership'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/UpdateMembership', + request_serializer=membership.UpdateMembershipRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_membership'] + + @property + def generate_connect_manifest(self) -> Callable[ + [membership.GenerateConnectManifestRequest], + Awaitable[membership.GenerateConnectManifestResponse]]: + r"""Return a callable for the generate connect manifest method over gRPC. + + Generates the manifest for deployment of the GKE + connect agent. + + Returns: + Callable[[~.GenerateConnectManifestRequest], + Awaitable[~.GenerateConnectManifestResponse]]: + 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 'generate_connect_manifest' not in self._stubs: + self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateConnectManifest', + request_serializer=membership.GenerateConnectManifestRequest.serialize, + response_deserializer=membership.GenerateConnectManifestResponse.deserialize, + ) + return self._stubs['generate_connect_manifest'] + + @property + def validate_exclusivity(self) -> Callable[ + [membership.ValidateExclusivityRequest], + Awaitable[membership.ValidateExclusivityResponse]]: + r"""Return a callable for the validate exclusivity method over gRPC. + + ValidateExclusivity validates the state of + exclusivity in the cluster. The validation does not + depend on an existing Hub membership resource. + + Returns: + Callable[[~.ValidateExclusivityRequest], + Awaitable[~.ValidateExclusivityResponse]]: + 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 'validate_exclusivity' not in self._stubs: + self._stubs['validate_exclusivity'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ValidateExclusivity', + request_serializer=membership.ValidateExclusivityRequest.serialize, + response_deserializer=membership.ValidateExclusivityResponse.deserialize, + ) + return self._stubs['validate_exclusivity'] + + @property + def generate_exclusivity_manifest(self) -> Callable[ + [membership.GenerateExclusivityManifestRequest], + Awaitable[membership.GenerateExclusivityManifestResponse]]: + r"""Return a callable for the generate exclusivity manifest method over gRPC. + + GenerateExclusivityManifest generates the manifests + to update the exclusivity artifacts in the cluster if + needed. + Exclusivity artifacts include the Membership custom + resource definition (CRD) and the singleton Membership + custom resource (CR). Combined with ValidateExclusivity, + exclusivity artifacts guarantee that a Kubernetes + cluster is only registered to a single GKE Hub. + + The Membership CRD is versioned, and may require + conversion when the GKE Hub API server begins serving a + newer version of the CRD and corresponding CR. The + response will be the converted CRD and CR if there are + any differences between the versions. + + Returns: + Callable[[~.GenerateExclusivityManifestRequest], + Awaitable[~.GenerateExclusivityManifestResponse]]: + 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 'generate_exclusivity_manifest' not in self._stubs: + self._stubs['generate_exclusivity_manifest'] = self.grpc_channel.unary_unary( + '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateExclusivityManifest', + request_serializer=membership.GenerateExclusivityManifestRequest.serialize, + response_deserializer=membership.GenerateExclusivityManifestResponse.deserialize, + ) + return self._stubs['generate_exclusivity_manifest'] + + +__all__ = ( + 'GkeHubMembershipServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py new file mode 100644 index 0000000..21cfed6 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .membership import ( + Authority, + ConnectAgent, + ConnectAgentResource, + CreateMembershipRequest, + DeleteMembershipRequest, + GenerateConnectManifestRequest, + GenerateConnectManifestResponse, + GenerateExclusivityManifestRequest, + GenerateExclusivityManifestResponse, + GetMembershipRequest, + GkeCluster, + KubernetesMetadata, + KubernetesResource, + ListMembershipsRequest, + ListMembershipsResponse, + Membership, + MembershipEndpoint, + MembershipState, + OperationMetadata, + ResourceManifest, + ResourceOptions, + TypeMeta, + UpdateMembershipRequest, + ValidateExclusivityRequest, + ValidateExclusivityResponse, +) + +__all__ = ( + 'Authority', + 'ConnectAgent', + 'ConnectAgentResource', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'GenerateExclusivityManifestRequest', + 'GenerateExclusivityManifestResponse', + 'GetMembershipRequest', + 'GkeCluster', + 'KubernetesMetadata', + 'KubernetesResource', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'Membership', + 'MembershipEndpoint', + 'MembershipState', + 'OperationMetadata', + 'ResourceManifest', + 'ResourceOptions', + 'TypeMeta', + 'UpdateMembershipRequest', + 'ValidateExclusivityRequest', + 'ValidateExclusivityResponse', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py new file mode 100644 index 0000000..8169b7a --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py @@ -0,0 +1,1075 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import proto # type: ignore + +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.gkehub.v1beta1', + manifest={ + 'Membership', + 'MembershipEndpoint', + 'KubernetesResource', + 'ResourceOptions', + 'ResourceManifest', + 'GkeCluster', + 'KubernetesMetadata', + 'Authority', + 'MembershipState', + 'ListMembershipsRequest', + 'ListMembershipsResponse', + 'GetMembershipRequest', + 'CreateMembershipRequest', + 'DeleteMembershipRequest', + 'UpdateMembershipRequest', + 'GenerateConnectManifestRequest', + 'GenerateConnectManifestResponse', + 'ConnectAgentResource', + 'TypeMeta', + 'ConnectAgent', + 'ValidateExclusivityRequest', + 'ValidateExclusivityResponse', + 'GenerateExclusivityManifestRequest', + 'GenerateExclusivityManifestResponse', + 'OperationMetadata', + }, +) + + +class Membership(proto.Message): + r"""Membership contains information about a member cluster. + Attributes: + name (str): + Output only. The full, unique name of this Membership + resource in the format + ``projects/*/locations/*/memberships/{membership_id}``, set + during creation. + + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + labels (Sequence[google.cloud.gkehub_v1beta1.types.Membership.LabelsEntry]): + Optional. GCP labels for this membership. + description (str): + Required. Description of this membership, limited to 63 + characters. Must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.\ ]*`` + endpoint (google.cloud.gkehub_v1beta1.types.MembershipEndpoint): + Optional. Endpoint information to reach this + member. + state (google.cloud.gkehub_v1beta1.types.MembershipState): + Output only. State of the Membership + resource. + authority (google.cloud.gkehub_v1beta1.types.Authority): + Optional. How to identify workloads from this + Membership. See the documentation on Workload + Identity for more details: + https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was last + updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. When the Membership was deleted. + external_id (str): + Optional. An externally-generated and managed ID for this + Membership. This ID may be modified after creation, but this + is not recommended. For GKE clusters, external_id is managed + by the Hub API and updates will be ignored. + + The ID must match the regex: + ``[a-zA-Z0-9][a-zA-Z0-9_\-\.]*`` + + If this Membership represents a Kubernetes cluster, this + value should be set to the UID of the ``kube-system`` + namespace object. + last_connection_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. For clusters using Connect, the + timestamp of the most recent connection + established with Google Cloud. This time is + updated every several minutes, not continuously. + For clusters that do not use GKE Connect, or + that have never connected successfully, this + field will be unset. + unique_id (str): + Output only. Google-generated UUID for this resource. This + is unique across all Membership resources. If a Membership + resource is deleted and another resource with the same name + is created, it gets a different unique_id. + infrastructure_type (google.cloud.gkehub_v1beta1.types.Membership.InfrastructureType): + Optional. The infrastructure type this + Membership is running on. + """ + class InfrastructureType(proto.Enum): + r"""Specifies the infrastructure type of a Membership. + Infrastructure type is used by Hub to control infrastructure- + specific behavior, including pricing. + Each GKE distribution (on-GCP, on-Prem, on-X,...) will set this + field automatically, but Attached Clusters customers should + specify a type during registration. + """ + INFRASTRUCTURE_TYPE_UNSPECIFIED = 0 + ON_PREM = 1 + MULTI_CLOUD = 2 + + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + description = proto.Field( + proto.STRING, + number=3, + ) + endpoint = proto.Field( + proto.MESSAGE, + number=4, + oneof='type', + message='MembershipEndpoint', + ) + state = proto.Field( + proto.MESSAGE, + number=5, + message='MembershipState', + ) + authority = proto.Field( + proto.MESSAGE, + number=9, + message='Authority', + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + external_id = proto.Field( + proto.STRING, + number=10, + ) + last_connection_time = proto.Field( + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + unique_id = proto.Field( + proto.STRING, + number=12, + ) + infrastructure_type = proto.Field( + proto.ENUM, + number=13, + enum=InfrastructureType, + ) + + +class MembershipEndpoint(proto.Message): + r"""MembershipEndpoint contains information needed to contact a + Kubernetes API, endpoint and any additional Kubernetes metadata. + + Attributes: + gke_cluster (google.cloud.gkehub_v1beta1.types.GkeCluster): + Optional. GKE-specific information. Only + present if this Membership is a GKE cluster. + kubernetes_metadata (google.cloud.gkehub_v1beta1.types.KubernetesMetadata): + Output only. Useful Kubernetes-specific + metadata. + kubernetes_resource (google.cloud.gkehub_v1beta1.types.KubernetesResource): + Optional. The in-cluster Kubernetes Resources that should be + applied for a correctly registered cluster, in the steady + state. These resources: + + - Ensure that the cluster is exclusively registered to one + and only one Hub Membership. + - Propagate Workload Pool Information available in the + Membership Authority field. + - Ensure proper initial configuration of default Hub + Features. + """ + + gke_cluster = proto.Field( + proto.MESSAGE, + number=4, + message='GkeCluster', + ) + kubernetes_metadata = proto.Field( + proto.MESSAGE, + number=5, + message='KubernetesMetadata', + ) + kubernetes_resource = proto.Field( + proto.MESSAGE, + number=6, + message='KubernetesResource', + ) + + +class KubernetesResource(proto.Message): + r"""KubernetesResource contains the YAML manifests and + configuration for Membership Kubernetes resources in the + cluster. After CreateMembership or UpdateMembership, these + resources should be re-applied in the cluster. + + Attributes: + membership_cr_manifest (str): + Input only. The YAML representation of the + Membership CR. This field is ignored for GKE + clusters where Hub can read the CR directly. + Callers should provide the CR that is currently + present in the cluster during CreateMembership + or UpdateMembership, or leave this field empty + if none exists. The CR manifest is used to + validate the cluster has not been registered + with another Membership. + membership_resources (Sequence[google.cloud.gkehub_v1beta1.types.ResourceManifest]): + Output only. Additional Kubernetes resources + that need to be applied to the cluster after + Membership creation, and after every update. + This field is only populated in the Membership + returned from a successful long-running + operation from CreateMembership or + UpdateMembership. It is not populated during + normal GetMembership or ListMemberships + requests. To get the resource manifest after the + initial registration, the caller should make a + UpdateMembership call with an empty field mask. + connect_resources (Sequence[google.cloud.gkehub_v1beta1.types.ResourceManifest]): + Output only. The Kubernetes resources for + installing the GKE Connect agent + This field is only populated in the Membership + returned from a successful long-running + operation from CreateMembership or + UpdateMembership. It is not populated during + normal GetMembership or ListMemberships + requests. To get the resource manifest after the + initial registration, the caller should make a + UpdateMembership call with an empty field mask. + resource_options (google.cloud.gkehub_v1beta1.types.ResourceOptions): + Optional. Options for Kubernetes resource + generation. + """ + + membership_cr_manifest = proto.Field( + proto.STRING, + number=1, + ) + membership_resources = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='ResourceManifest', + ) + connect_resources = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ResourceManifest', + ) + resource_options = proto.Field( + proto.MESSAGE, + number=4, + message='ResourceOptions', + ) + + +class ResourceOptions(proto.Message): + r"""ResourceOptions represent options for Kubernetes resource + generation. + + Attributes: + connect_version (str): + Optional. The Connect agent version to use for + connect_resources. Defaults to the latest GKE Connect + version. The version must be a currently supported version, + obsolete versions will be rejected. + v1beta1_crd (bool): + Optional. Use ``apiextensions/v1beta1`` instead of + ``apiextensions/v1`` for CustomResourceDefinition resources. + This option should be set for clusters with Kubernetes + apiserver versions <1.16. + """ + + connect_version = proto.Field( + proto.STRING, + number=1, + ) + v1beta1_crd = proto.Field( + proto.BOOL, + number=2, + ) + + +class ResourceManifest(proto.Message): + r"""ResourceManifest represents a single Kubernetes resource to + be applied to the cluster. + + Attributes: + manifest (str): + YAML manifest of the resource. + cluster_scoped (bool): + Whether the resource provided in the manifest is + ``cluster_scoped``. If unset, the manifest is assumed to be + namespace scoped. + + This field is used for REST mapping when applying the + resource in a cluster. + """ + + manifest = proto.Field( + proto.STRING, + number=1, + ) + cluster_scoped = proto.Field( + proto.BOOL, + number=2, + ) + + +class GkeCluster(proto.Message): + r"""GkeCluster contains information specific to GKE clusters. + Attributes: + resource_link (str): + Immutable. Self-link of the GCP resource for + the GKE cluster. For example: + > container.googleapis.com/projects/my- + project/locations/us-west1-a/clusters/my-cluster + Zonal clusters are also supported. + """ + + resource_link = proto.Field( + proto.STRING, + number=1, + ) + + +class KubernetesMetadata(proto.Message): + r"""KubernetesMetadata provides informational metadata for + Memberships representing Kubernetes clusters. + + Attributes: + kubernetes_api_server_version (str): + Output only. Kubernetes API server version + string as reported by '/version'. + node_provider_id (str): + Output only. Node providerID as reported by the first node + in the list of nodes on the Kubernetes endpoint. On + Kubernetes platforms that support zero-node clusters (like + GKE-on-GCP), the node_count will be zero and the + node_provider_id will be empty. + node_count (int): + Output only. Node count as reported by + Kubernetes nodes resources. + vcpu_count (int): + Output only. vCPU count as reported by + Kubernetes nodes resources. + memory_mb (int): + Output only. The total memory capacity as + reported by the sum of all Kubernetes nodes + resources, defined in MB. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which these details were last + updated. This update_time is different from the + Membership-level update_time since EndpointDetails are + updated internally for API consumers. + """ + + kubernetes_api_server_version = proto.Field( + proto.STRING, + number=1, + ) + node_provider_id = proto.Field( + proto.STRING, + number=2, + ) + node_count = proto.Field( + proto.INT32, + number=3, + ) + vcpu_count = proto.Field( + proto.INT32, + number=4, + ) + memory_mb = proto.Field( + proto.INT32, + number=5, + ) + update_time = proto.Field( + proto.MESSAGE, + number=100, + message=timestamp_pb2.Timestamp, + ) + + +class Authority(proto.Message): + r"""Authority encodes how Google will recognize identities from + this Membership. See the workload identity documentation for + more details: https://cloud.google.com/kubernetes- + engine/docs/how-to/workload-identity + + Attributes: + issuer (str): + Optional. A JSON Web Token (JWT) issuer URI. ``issuer`` must + start with ``https://`` and be a valid URL with length <2000 + characters. + + If set, then Google will allow valid OIDC tokens from this + issuer to authenticate within the workload_identity_pool. + OIDC discovery will be performed on this URI to validate + tokens from the issuer. + + Clearing ``issuer`` disables Workload Identity. ``issuer`` + cannot be directly modified; it must be cleared (and + Workload Identity disabled) before using a new issuer (and + re-enabling Workload Identity). + workload_identity_pool (str): + Output only. The name of the workload identity pool in which + ``issuer`` will be recognized. + + There is a single Workload Identity Pool per Hub that is + shared between all Memberships that belong to that Hub. For + a Hub hosted in {PROJECT_ID}, the workload pool format is + ``{PROJECT_ID}.hub.id.goog``, although this is subject to + change in newer versions of this API. + identity_provider (str): + Output only. An identity provider that reflects the + ``issuer`` in the workload identity pool. + oidc_jwks (bytes): + Optional. OIDC verification keys for this Membership in JWKS + format (RFC 7517). + + When this field is set, OIDC discovery will NOT be performed + on ``issuer``, and instead OIDC tokens will be validated + using this field. + """ + + issuer = proto.Field( + proto.STRING, + number=1, + ) + workload_identity_pool = proto.Field( + proto.STRING, + number=2, + ) + identity_provider = proto.Field( + proto.STRING, + number=3, + ) + oidc_jwks = proto.Field( + proto.BYTES, + number=4, + ) + + +class MembershipState(proto.Message): + r"""State of the Membership resource. + Attributes: + code (google.cloud.gkehub_v1beta1.types.MembershipState.Code): + Output only. The current state of the + Membership resource. + description (str): + This field is never set by the Hub Service. + update_time (google.protobuf.timestamp_pb2.Timestamp): + This field is never set by the Hub Service. + """ + class Code(proto.Enum): + r"""Code describes the state of a Membership resource.""" + CODE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + UPDATING = 4 + SERVICE_UPDATING = 5 + + code = proto.Field( + proto.ENUM, + number=1, + enum=Code, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + + +class ListMembershipsRequest(proto.Message): + r"""Request message for ``GkeHubMembershipService.ListMemberships`` + method. + + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be listed. Specified in the format + ``projects/*/locations/*``. + page_size (int): + Optional. When requesting a 'page' of resources, + ``page_size`` specifies number of resources to return. If + unspecified or set to 0, all resources will be returned. + page_token (str): + Optional. Token returned by previous call to + ``ListMemberships`` which specifies the position in the list + from where to continue listing the resources. + filter (str): + Optional. Lists Memberships that match the filter + expression, following the syntax outlined in + https://google.aip.dev/160. + + Examples: + + - Name is ``bar`` in project ``foo-proj`` and location + ``global``: + + name = + "projects/foo-proj/locations/global/membership/bar" + + - Memberships that have a label called ``foo``: + + labels.foo:\* + + - Memberships that have a label called ``foo`` whose value + is ``bar``: + + labels.foo = bar + + - Memberships in the CREATING state: + + state = CREATING + order_by (str): + Optional. One or more fields to compare and + use to sort the output. See + https://google.aip.dev/132#ordering. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListMembershipsResponse(proto.Message): + r"""Response message for the ``GkeHubMembershipService.ListMemberships`` + method. + + Attributes: + resources (Sequence[google.cloud.gkehub_v1beta1.types.Membership]): + The list of matching Memberships. + next_page_token (str): + A token to request the next page of resources from the + ``ListMemberships`` method. The value of an empty string + means that there are no more resources to return. + unreachable (Sequence[str]): + List of locations that could not be reached + while fetching this list. + """ + + @property + def raw_page(self): + return self + + resources = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Membership', + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetMembershipRequest(proto.Message): + r"""Request message for ``GkeHubMembershipService.GetMembership`` + method. + + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateMembershipRequest(proto.Message): + r"""Request message for the ``GkeHubMembershipService.CreateMembership`` + method. + + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + membership_id (str): + Required. Client chosen ID for the membership. + ``membership_id`` must be a valid RFC 1123 compliant DNS + label: + + 1. At most 63 characters in length + 2. It must consist of lower case alphanumeric characters or + ``-`` + 3. It must start and end with an alphanumeric character + + Which can be expressed as the regex: + ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of + 63 characters. + resource (google.cloud.gkehub_v1beta1.types.Membership): + Required. The membership to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + membership_id = proto.Field( + proto.STRING, + number=2, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message='Membership', + ) + + +class DeleteMembershipRequest(proto.Message): + r"""Request message for ``GkeHubMembershipService.DeleteMembership`` + method. + + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateMembershipRequest(proto.Message): + r"""Request message for ``GkeHubMembershipService.UpdateMembership`` + method. + + Attributes: + name (str): + Required. The membership resource name in the format: + ``projects/[project_id]/locations/global/memberships/[membership_id]`` + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. At least + one field path must be specified in this mask. + resource (google.cloud.gkehub_v1beta1.types.Membership): + Required. Only fields specified in update_mask are updated. + If you specify a field in the update_mask but don't specify + its value here that field will be deleted. If you are + updating a map field, set the value of a key to null or + empty string to delete the key from the map. It's not + possible to update a key's value to the empty string. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + resource = proto.Field( + proto.MESSAGE, + number=3, + message='Membership', + ) + + +class GenerateConnectManifestRequest(proto.Message): + r"""Request message for + ``GkeHubMembershipService.GenerateConnectManifest`` method. . + + Attributes: + name (str): + Required. The Membership resource name the Agent will + associate with, in the format + ``projects/*/locations/*/memberships/*``. + connect_agent (google.cloud.gkehub_v1beta1.types.ConnectAgent): + Optional. The connect agent to generate + manifest for. + version (str): + Optional. The Connect agent version to use. + Defaults to the most current version. + is_upgrade (bool): + Optional. If true, generate the resources for + upgrade only. Some resources generated only for + installation (e.g. secrets) will be excluded. + registry (str): + Optional. The registry to fetch the connect + agent image from. Defaults to gcr.io/gkeconnect. + image_pull_secret_content (bytes): + Optional. The image pull secret content for + the registry, if not public. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + connect_agent = proto.Field( + proto.MESSAGE, + number=2, + message='ConnectAgent', + ) + version = proto.Field( + proto.STRING, + number=3, + ) + is_upgrade = proto.Field( + proto.BOOL, + number=4, + ) + registry = proto.Field( + proto.STRING, + number=5, + ) + image_pull_secret_content = proto.Field( + proto.BYTES, + number=6, + ) + + +class GenerateConnectManifestResponse(proto.Message): + r"""GenerateConnectManifestResponse contains manifest information + for installing/upgrading a Connect agent. + + Attributes: + manifest (Sequence[google.cloud.gkehub_v1beta1.types.ConnectAgentResource]): + The ordered list of Kubernetes resources that + need to be applied to the cluster for GKE + Connect agent installation/upgrade. + """ + + manifest = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='ConnectAgentResource', + ) + + +class ConnectAgentResource(proto.Message): + r"""ConnectAgentResource represents a Kubernetes resource + manifest for Connect Agent deployment. + + Attributes: + type_ (google.cloud.gkehub_v1beta1.types.TypeMeta): + Kubernetes type of the resource. + manifest (str): + YAML manifest of the resource. + """ + + type_ = proto.Field( + proto.MESSAGE, + number=1, + message='TypeMeta', + ) + manifest = proto.Field( + proto.STRING, + number=2, + ) + + +class TypeMeta(proto.Message): + r"""TypeMeta is the type information needed for content + unmarshalling of Kubernetes resources in the manifest. + + Attributes: + kind (str): + Kind of the resource (e.g. Deployment). + api_version (str): + APIVersion of the resource (e.g. v1). + """ + + kind = proto.Field( + proto.STRING, + number=1, + ) + api_version = proto.Field( + proto.STRING, + number=2, + ) + + +class ConnectAgent(proto.Message): + r"""The information required from end users to use GKE Connect. + Attributes: + name (str): + Do not set. + proxy (bytes): + Optional. URI of a proxy if connectivity from the agent to + gkeconnect.googleapis.com requires the use of a proxy. + Format must be in the form ``http(s)://{proxy_address}``, + depending on the HTTP/HTTPS protocol supported by the proxy. + This will direct the connect agent's outbound traffic + through a HTTP(S) proxy. + namespace (str): + Optional. Namespace for GKE Connect agent resources. + Defaults to ``gke-connect``. + + The Connect Agent is authorized automatically when run in + the default namespace. Otherwise, explicit authorization + must be granted with an additional IAM binding. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + proxy = proto.Field( + proto.BYTES, + number=2, + ) + namespace = proto.Field( + proto.STRING, + number=3, + ) + + +class ValidateExclusivityRequest(proto.Message): + r"""The request to validate the existing state of the membership + CR in the cluster. + + Attributes: + parent (str): + Required. The parent (project and location) where the + Memberships will be created. Specified in the format + ``projects/*/locations/*``. + cr_manifest (str): + Optional. The YAML of the membership CR in + the cluster. Empty if the membership CR does not + exist. + intended_membership (str): + Required. The intended membership name under the ``parent``. + This method only does validation in anticipation of a + CreateMembership call with the same name. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + cr_manifest = proto.Field( + proto.STRING, + number=2, + ) + intended_membership = proto.Field( + proto.STRING, + number=3, + ) + + +class ValidateExclusivityResponse(proto.Message): + r"""The response of exclusivity artifacts validation result + status. + + Attributes: + status (google.rpc.status_pb2.Status): + The validation result. + + - ``OK`` means that exclusivity is validated, assuming the + manifest produced by GenerateExclusivityManifest is + successfully applied. + - ``ALREADY_EXISTS`` means that the Membership CRD is + already owned by another Hub. See ``status.message`` for + more information. + """ + + status = proto.Field( + proto.MESSAGE, + number=1, + message=status_pb2.Status, + ) + + +class GenerateExclusivityManifestRequest(proto.Message): + r"""The request to generate the manifests for exclusivity + artifacts. + + Attributes: + name (str): + Required. The Membership resource name in the format + ``projects/*/locations/*/memberships/*``. + crd_manifest (str): + Optional. The YAML manifest of the membership CRD retrieved + by ``kubectl get customresourcedefinitions membership``. + Leave empty if the resource does not exist. + cr_manifest (str): + Optional. The YAML manifest of the membership CR retrieved + by ``kubectl get memberships membership``. Leave empty if + the resource does not exist. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + crd_manifest = proto.Field( + proto.STRING, + number=2, + ) + cr_manifest = proto.Field( + proto.STRING, + number=3, + ) + + +class GenerateExclusivityManifestResponse(proto.Message): + r"""The response of the exclusivity artifacts manifests for the + client to apply. + + Attributes: + crd_manifest (str): + The YAML manifest of the membership CRD to + apply if a newer version of the CRD is + available. Empty if no update needs to be + applied. + cr_manifest (str): + The YAML manifest of the membership CR to + apply if a new version of the CR is available. + Empty if no update needs to be applied. + """ + + crd_manifest = proto.Field( + proto.STRING, + number=1, + ) + cr_manifest = proto.Field( + proto.STRING, + number=2, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_detail (str): + Output only. Human-readable status of the + operation, if any. + cancel_requested (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/mypy.ini b/owl-bot-staging/v1beta1/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1beta1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1beta1/noxfile.py b/owl-bot-staging/v1beta1/noxfile.py new file mode 100644 index 0000000..2db93fe --- /dev/null +++ b/owl-bot-staging/v1beta1/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/gkehub_v1beta1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py b/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py new file mode 100644 index 0000000..b7bb67b --- /dev/null +++ b/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py @@ -0,0 +1,183 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class gkehubCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_membership': ('parent', 'membership_id', 'resource', ), + 'delete_membership': ('name', ), + 'generate_connect_manifest': ('name', 'connect_agent', 'version', 'is_upgrade', 'registry', 'image_pull_secret_content', ), + 'generate_exclusivity_manifest': ('name', 'crd_manifest', 'cr_manifest', ), + 'get_membership': ('name', ), + 'list_memberships': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_membership': ('name', 'update_mask', 'resource', ), + 'validate_exclusivity': ('parent', 'intended_membership', 'cr_manifest', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=gkehubCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the gkehub client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta1/setup.py b/owl-bot-staging/v1beta1/setup.py new file mode 100644 index 0000000..2c5fa00 --- /dev/null +++ b/owl-bot-staging/v1beta1/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-gke-hub', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1beta1/tests/__init__.py b/owl-bot-staging/v1beta1/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/__init__.py b/owl-bot-staging/v1beta1/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py new file mode 100644 index 0000000..fe700b5 --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py @@ -0,0 +1,2803 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +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 operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import GkeHubMembershipServiceAsyncClient +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import GkeHubMembershipServiceClient +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import transports +from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1beta1.types import membership +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(None) is None + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + GkeHubMembershipServiceClient, + GkeHubMembershipServiceAsyncClient, +]) +def test_gke_hub_membership_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + GkeHubMembershipServiceClient, + GkeHubMembershipServiceAsyncClient, +]) +def test_gke_hub_membership_service_client_service_account_always_use_jwt(client_class): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + +@pytest.mark.parametrize("client_class", [ + GkeHubMembershipServiceClient, + GkeHubMembershipServiceAsyncClient, +]) +def test_gke_hub_membership_service_client_from_service_account_file(client_class): + 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") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_membership_service_client_get_transport_class(): + transport = GkeHubMembershipServiceClient.get_transport_class() + available_transports = [ + transports.GkeHubMembershipServiceGrpcTransport, + ] + assert transport in available_transports + + transport = GkeHubMembershipServiceClient.get_transport_class("grpc") + assert transport == transports.GkeHubMembershipServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), + (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(GkeHubMembershipServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceClient)) +@mock.patch.object(GkeHubMembershipServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceAsyncClient)) +def test_gke_hub_membership_service_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(GkeHubMembershipServiceClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(GkeHubMembershipServiceClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc", "true"), + (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc", "false"), + (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(GkeHubMembershipServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceClient)) +@mock.patch.object(GkeHubMembershipServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_gke_hub_membership_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), + (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_membership_service_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + 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) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), + (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_gke_hub_membership_service_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_gke_hub_membership_service_client_client_options_from_dict(): + with mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = GkeHubMembershipServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_list_memberships(transport: str = 'grpc', request_type=membership.ListMembershipsRequest): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_memberships(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_memberships_from_dict(): + test_list_memberships(request_type=dict) + + +def test_list_memberships_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 = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + client.list_memberships() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + +@pytest.mark.asyncio +async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=membership.ListMembershipsRequest): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_memberships(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ListMembershipsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMembershipsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_memberships_async_from_dict(): + await test_list_memberships_async(request_type=dict) + + +def test_list_memberships_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = membership.ListMembershipsResponse() + client.list_memberships(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_memberships_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.ListMembershipsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + await client.list_memberships(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_memberships_flattened(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +def test_list_memberships_flattened_error(): + client = GkeHubMembershipServiceClient( + 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_memberships( + membership.ListMembershipsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_async(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ListMembershipsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_memberships( + 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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_memberships_flattened_error_async(): + client = GkeHubMembershipServiceAsyncClient( + 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_memberships( + membership.ListMembershipsRequest(), + parent='parent_value', + ) + + +def test_list_memberships_pager(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_memberships(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, membership.Membership) + for i in results) + +def test_list_memberships_pages(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = list(client.list_memberships(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_memberships_async_pager(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_memberships(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, membership.Membership) + for i in responses) + +@pytest.mark.asyncio +async def test_list_memberships_async_pages(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_memberships), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + membership.Membership(), + ], + next_page_token='abc', + ), + membership.ListMembershipsResponse( + resources=[], + next_page_token='def', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + ], + next_page_token='ghi', + ), + membership.ListMembershipsResponse( + resources=[ + membership.Membership(), + membership.Membership(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_memberships(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_membership(transport: str = 'grpc', request_type=membership.GetMembershipRequest): + client = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, + endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), + ) + response = client.get_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + + +def test_get_membership_from_dict(): + test_get_membership(request_type=dict) + + +def test_get_membership_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 = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + client.get_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + +@pytest.mark.asyncio +async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=membership.GetMembershipRequest): + client = GkeHubMembershipServiceAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( + name='name_value', + description='description_value', + external_id='external_id_value', + unique_id='unique_id_value', + infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, + )) + response = await client.get_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GetMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.Membership) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.external_id == 'external_id_value' + assert response.unique_id == 'unique_id_value' + assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + + +@pytest.mark.asyncio +async def test_get_membership_async_from_dict(): + await test_get_membership_async(request_type=dict) + + +def test_get_membership_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = membership.Membership() + client.get_membership(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_membership_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.GetMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + await client.get_membership(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_membership_flattened(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_membership_flattened_error(): + client = GkeHubMembershipServiceClient( + 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_membership( + membership.GetMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_membership_flattened_async(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.Membership() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_membership_flattened_error_async(): + client = GkeHubMembershipServiceAsyncClient( + 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_membership( + membership.GetMembershipRequest(), + name='name_value', + ) + + +def test_create_membership(transport: str = 'grpc', request_type=membership.CreateMembershipRequest): + client = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_membership_from_dict(): + test_create_membership(request_type=dict) + + +def test_create_membership_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 = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + client.create_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + +@pytest.mark.asyncio +async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=membership.CreateMembershipRequest): + client = GkeHubMembershipServiceAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.CreateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_membership_async_from_dict(): + await test_create_membership_async(request_type=dict) + + +def test_create_membership_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_membership(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_membership_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.CreateMembershipRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_membership(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_membership_flattened(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_membership( + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].membership_id == 'membership_id_value' + + +def test_create_membership_flattened_error(): + client = GkeHubMembershipServiceClient( + 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_membership( + membership.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_membership_flattened_async(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_membership( + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_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] + assert args[0].parent == 'parent_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].membership_id == 'membership_id_value' + + +@pytest.mark.asyncio +async def test_create_membership_flattened_error_async(): + client = GkeHubMembershipServiceAsyncClient( + 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_membership( + membership.CreateMembershipRequest(), + parent='parent_value', + resource=membership.Membership(name='name_value'), + membership_id='membership_id_value', + ) + + +def test_delete_membership(transport: str = 'grpc', request_type=membership.DeleteMembershipRequest): + client = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_membership_from_dict(): + test_delete_membership(request_type=dict) + + +def test_delete_membership_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 = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + client.delete_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + +@pytest.mark.asyncio +async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=membership.DeleteMembershipRequest): + client = GkeHubMembershipServiceAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.DeleteMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_membership_async_from_dict(): + await test_delete_membership_async(request_type=dict) + + +def test_delete_membership_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_membership(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_membership_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.DeleteMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_membership(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_membership_flattened(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_membership_flattened_error(): + client = GkeHubMembershipServiceClient( + 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_membership( + membership.DeleteMembershipRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_async(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_membership( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_membership_flattened_error_async(): + client = GkeHubMembershipServiceAsyncClient( + 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_membership( + membership.DeleteMembershipRequest(), + name='name_value', + ) + + +def test_update_membership(transport: str = 'grpc', request_type=membership.UpdateMembershipRequest): + client = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_membership_from_dict(): + test_update_membership(request_type=dict) + + +def test_update_membership_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 = GkeHubMembershipServiceClient( + 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_membership), + '__call__') as call: + client.update_membership() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + +@pytest.mark.asyncio +async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=membership.UpdateMembershipRequest): + client = GkeHubMembershipServiceAsyncClient( + 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_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_membership(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.UpdateMembershipRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_membership_async_from_dict(): + await test_update_membership_async(request_type=dict) + + +def test_update_membership_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_membership(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_update_membership_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.UpdateMembershipRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_membership(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_update_membership_flattened(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_membership( + name='name_value', + resource=membership.Membership(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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_membership_flattened_error(): + client = GkeHubMembershipServiceClient( + 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_membership( + membership.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_async(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_membership), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_membership( + name='name_value', + resource=membership.Membership(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] + assert args[0].name == 'name_value' + assert args[0].resource == membership.Membership(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_membership_flattened_error_async(): + client = GkeHubMembershipServiceAsyncClient( + 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_membership( + membership.UpdateMembershipRequest(), + name='name_value', + resource=membership.Membership(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_generate_connect_manifest(transport: str = 'grpc', request_type=membership.GenerateConnectManifestRequest): + client = GkeHubMembershipServiceClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.GenerateConnectManifestResponse( + ) + response = client.generate_connect_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateConnectManifestResponse) + + +def test_generate_connect_manifest_from_dict(): + test_generate_connect_manifest(request_type=dict) + + +def test_generate_connect_manifest_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 = GkeHubMembershipServiceClient( + 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.generate_connect_manifest), + '__call__') as call: + client.generate_connect_manifest() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateConnectManifestRequest): + client = GkeHubMembershipServiceAsyncClient( + 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.generate_connect_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse( + )) + response = await client.generate_connect_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateConnectManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateConnectManifestResponse) + + +@pytest.mark.asyncio +async def test_generate_connect_manifest_async_from_dict(): + await test_generate_connect_manifest_async(request_type=dict) + + +def test_generate_connect_manifest_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = membership.GenerateConnectManifestResponse() + client.generate_connect_manifest(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_generate_connect_manifest_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.GenerateConnectManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_connect_manifest), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse()) + await client.generate_connect_manifest(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_validate_exclusivity(transport: str = 'grpc', request_type=membership.ValidateExclusivityRequest): + client = GkeHubMembershipServiceClient( + 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.validate_exclusivity), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.ValidateExclusivityResponse( + ) + response = client.validate_exclusivity(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ValidateExclusivityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.ValidateExclusivityResponse) + + +def test_validate_exclusivity_from_dict(): + test_validate_exclusivity(request_type=dict) + + +def test_validate_exclusivity_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 = GkeHubMembershipServiceClient( + 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.validate_exclusivity), + '__call__') as call: + client.validate_exclusivity() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ValidateExclusivityRequest() + + +@pytest.mark.asyncio +async def test_validate_exclusivity_async(transport: str = 'grpc_asyncio', request_type=membership.ValidateExclusivityRequest): + client = GkeHubMembershipServiceAsyncClient( + 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.validate_exclusivity), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ValidateExclusivityResponse( + )) + response = await client.validate_exclusivity(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.ValidateExclusivityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.ValidateExclusivityResponse) + + +@pytest.mark.asyncio +async def test_validate_exclusivity_async_from_dict(): + await test_validate_exclusivity_async(request_type=dict) + + +def test_validate_exclusivity_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.ValidateExclusivityRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_exclusivity), + '__call__') as call: + call.return_value = membership.ValidateExclusivityResponse() + client.validate_exclusivity(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_validate_exclusivity_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.ValidateExclusivityRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_exclusivity), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ValidateExclusivityResponse()) + await client.validate_exclusivity(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_generate_exclusivity_manifest(transport: str = 'grpc', request_type=membership.GenerateExclusivityManifestRequest): + client = GkeHubMembershipServiceClient( + 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.generate_exclusivity_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = membership.GenerateExclusivityManifestResponse( + crd_manifest='crd_manifest_value', + cr_manifest='cr_manifest_value', + ) + response = client.generate_exclusivity_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateExclusivityManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateExclusivityManifestResponse) + assert response.crd_manifest == 'crd_manifest_value' + assert response.cr_manifest == 'cr_manifest_value' + + +def test_generate_exclusivity_manifest_from_dict(): + test_generate_exclusivity_manifest(request_type=dict) + + +def test_generate_exclusivity_manifest_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 = GkeHubMembershipServiceClient( + 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.generate_exclusivity_manifest), + '__call__') as call: + client.generate_exclusivity_manifest() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateExclusivityManifestRequest() + + +@pytest.mark.asyncio +async def test_generate_exclusivity_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateExclusivityManifestRequest): + client = GkeHubMembershipServiceAsyncClient( + 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.generate_exclusivity_manifest), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateExclusivityManifestResponse( + crd_manifest='crd_manifest_value', + cr_manifest='cr_manifest_value', + )) + response = await client.generate_exclusivity_manifest(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == membership.GenerateExclusivityManifestRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, membership.GenerateExclusivityManifestResponse) + assert response.crd_manifest == 'crd_manifest_value' + assert response.cr_manifest == 'cr_manifest_value' + + +@pytest.mark.asyncio +async def test_generate_exclusivity_manifest_async_from_dict(): + await test_generate_exclusivity_manifest_async(request_type=dict) + + +def test_generate_exclusivity_manifest_field_headers(): + client = GkeHubMembershipServiceClient( + 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 = membership.GenerateExclusivityManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_exclusivity_manifest), + '__call__') as call: + call.return_value = membership.GenerateExclusivityManifestResponse() + client.generate_exclusivity_manifest(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_generate_exclusivity_manifest_field_headers_async(): + client = GkeHubMembershipServiceAsyncClient( + 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 = membership.GenerateExclusivityManifestRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.generate_exclusivity_manifest), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateExclusivityManifestResponse()) + await client.generate_exclusivity_manifest(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_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.GkeHubMembershipServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.GkeHubMembershipServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubMembershipServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.GkeHubMembershipServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = GkeHubMembershipServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubMembershipServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = GkeHubMembershipServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.GkeHubMembershipServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.GkeHubMembershipServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.GkeHubMembershipServiceGrpcTransport, + transports.GkeHubMembershipServiceGrpcAsyncIOTransport, +]) +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() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.GkeHubMembershipServiceGrpcTransport, + ) + +def test_gke_hub_membership_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.GkeHubMembershipServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_gke_hub_membership_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.GkeHubMembershipServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_memberships', + 'get_membership', + 'create_membership', + 'delete_membership', + 'update_membership', + 'generate_connect_manifest', + 'validate_exclusivity', + 'generate_exclusivity_manifest', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_membership_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('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubMembershipServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_membership_service_base_transport_with_credentials_file_old_google_auth(): + # 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('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubMembershipServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_gke_hub_membership_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.GkeHubMembershipServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_gke_hub_membership_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubMembershipServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_gke_hub_membership_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + GkeHubMembershipServiceClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubMembershipServiceGrpcTransport, + transports.GkeHubMembershipServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_gke_hub_membership_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.GkeHubMembershipServiceGrpcTransport, + transports.GkeHubMembershipServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_gke_hub_membership_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.GkeHubMembershipServiceGrpcTransport, grpc_helpers), + (transports.GkeHubMembershipServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_gke_hub_membership_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "gkehub.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="gkehub.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) +def test_gke_hub_membership_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_gke_hub_membership_service_host_no_port(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + ) + assert client.transport._host == 'gkehub.googleapis.com:443' + + +def test_gke_hub_membership_service_host_with_port(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + ) + assert client.transport._host == 'gkehub.googleapis.com:8000' + +def test_gke_hub_membership_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubMembershipServiceGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_gke_hub_membership_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.GkeHubMembershipServiceGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) +def test_gke_hub_membership_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) +def test_gke_hub_membership_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_gke_hub_membership_service_grpc_lro_client(): + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_gke_hub_membership_service_grpc_lro_async_client(): + client = GkeHubMembershipServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_membership_path(): + project = "squid" + location = "clam" + membership = "whelk" + expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + actual = GkeHubMembershipServiceClient.membership_path(project, location, membership) + assert expected == actual + + +def test_parse_membership_path(): + expected = { + "project": "octopus", + "location": "oyster", + "membership": "nudibranch", + } + path = GkeHubMembershipServiceClient.membership_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_membership_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = GkeHubMembershipServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = GkeHubMembershipServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = GkeHubMembershipServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = GkeHubMembershipServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = GkeHubMembershipServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = GkeHubMembershipServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = GkeHubMembershipServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = GkeHubMembershipServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = GkeHubMembershipServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = GkeHubMembershipServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = GkeHubMembershipServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.GkeHubMembershipServiceTransport, '_prep_wrapped_messages') as prep: + client = GkeHubMembershipServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.GkeHubMembershipServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = GkeHubMembershipServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) From 5ece39cd8241c8d74a4748a12025260524f8983a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 29 Jun 2021 02:26:34 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md --- .../cloudauditlogging_v1alpha/services.rst | 0 .../cloudauditlogging_v1alpha/types.rst | 0 .../configmanagement_v1/services.rst | 0 .../configmanagement_v1/types.rst | 0 .../configmanagement_v1alpha/services.rst | 0 .../configmanagement_v1alpha/types.rst | 0 .../configmanagement_v1beta/services.rst | 0 .../configmanagement_v1beta/types.rst | 0 .../v1/docs => docs}/gkehub_v1/gke_hub.rst | 0 .../v1/docs => docs}/gkehub_v1/services.rst | 0 .../v1/docs => docs}/gkehub_v1/types.rst | 0 .../docs => docs}/gkehub_v1alpha/gke_hub.rst | 0 .../docs => docs}/gkehub_v1alpha/services.rst | 0 .../docs => docs}/gkehub_v1alpha/types.rst | 0 .../docs => docs}/gkehub_v1alpha2/gke_hub.rst | 0 .../gkehub_v1alpha2/services.rst | 0 .../docs => docs}/gkehub_v1alpha2/types.rst | 0 .../docs => docs}/gkehub_v1beta/gke_hub.rst | 0 .../docs => docs}/gkehub_v1beta/services.rst | 0 .../docs => docs}/gkehub_v1beta/types.rst | 0 .../metering_v1alpha/services.rst | 0 .../docs => docs}/metering_v1alpha/types.rst | 0 .../metering_v1beta/services.rst | 0 .../docs => docs}/metering_v1beta/types.rst | 0 .../multiclusteringress_v1/services.rst | 0 .../multiclusteringress_v1/types.rst | 0 .../multiclusteringress_v1alpha/services.rst | 0 .../multiclusteringress_v1alpha/types.rst | 0 .../multiclusteringress_v1beta/services.rst | 0 .../multiclusteringress_v1beta/types.rst | 0 .../servicemesh_v1alpha/services.rst | 0 .../servicemesh_v1alpha/types.rst | 0 .../gkehub/cloudauditlogging/__init__.py | 7 +- .../cloud/gkehub/cloudauditlogging/py.typed | 0 .../cloudauditlogging_v1alpha/__init__.py | 4 +- .../gapic_metadata.json | 0 .../gkehub/cloudauditlogging_v1alpha/py.typed | 0 .../services/__init__.py | 0 .../types/__init__.py | 18 + .../types/cloudauditlogging.py | 10 +- .../cloud/gkehub/configmanagement/__init__.py | 139 +- .../cloud/gkehub/configmanagement/py.typed | 0 .../gkehub/configmanagement_v1/__init__.py | 44 +- .../configmanagement_v1/gapic_metadata.json | 0 .../cloud/gkehub/configmanagement_v1/py.typed | 0 .../configmanagement_v1}/services/__init__.py | 0 .../configmanagement_v1/types/__init__.py | 44 +- .../types/configmanagement.py | 440 +-- .../configmanagement_v1alpha/__init__.py | 50 +- .../gapic_metadata.json | 0 .../gkehub/configmanagement_v1alpha}/py.typed | 0 .../services/__init__.py | 0 .../types/__init__.py | 50 +- .../types/configmanagement.py | 491 +-- .../configmanagement_v1beta/__init__.py | 50 +- .../gapic_metadata.json | 0 .../gkehub/configmanagement_v1beta}/py.typed | 0 .../services/__init__.py | 0 .../configmanagement_v1beta/types/__init__.py | 50 +- .../types/configmanagement.py | 480 +-- .../cloud/gkehub/metering/__init__.py | 3 +- .../cloud/gkehub/metering/py.typed | 0 .../cloud/gkehub/metering_v1alpha/__init__.py | 4 +- .../metering_v1alpha/gapic_metadata.json | 0 .../cloud/gkehub/metering_v1alpha/py.typed | 0 .../metering_v1alpha}/services/__init__.py | 0 .../gkehub/metering_v1alpha/types/__init__.py | 18 + .../metering_v1alpha}/types/metering.py | 14 +- .../cloud/gkehub/metering_v1beta/__init__.py | 4 +- .../metering_v1beta/gapic_metadata.json | 0 .../cloud/gkehub/metering_v1beta}/py.typed | 0 .../metering_v1beta}/services/__init__.py | 0 .../gkehub/metering_v1beta/types/__init__.py | 18 + .../gkehub/metering_v1beta}/types/metering.py | 14 +- .../gkehub/multiclusteringress/__init__.py | 13 +- .../cloud/gkehub/multiclusteringress/py.typed | 0 .../gkehub/multiclusteringress_v1/__init__.py | 4 +- .../gapic_metadata.json | 0 .../gkehub/multiclusteringress_v1/py.typed | 0 .../services/__init__.py | 0 .../multiclusteringress_v1/types/__init__.py | 18 + .../types/multiclusteringress.py | 10 +- .../multiclusteringress_v1alpha}/__init__.py | 4 +- .../gapic_metadata.json | 0 .../multiclusteringress_v1alpha}/py.typed | 0 .../services/__init__.py | 0 .../types/__init__.py | 4 +- .../types/multiclusteringress.py | 18 +- .../multiclusteringress_v1beta}/__init__.py | 4 +- .../gapic_metadata.json | 0 .../multiclusteringress_v1beta}/py.typed | 0 .../services/__init__.py | 0 .../types/__init__.py | 4 +- .../types/multiclusteringress.py | 18 +- .../cloud/gkehub/servicemesh/__init__.py | 13 +- .../cloud/gkehub/servicemesh/py.typed | 0 .../gkehub/servicemesh_v1alpha/__init__.py | 8 +- .../servicemesh_v1alpha/gapic_metadata.json | 0 .../cloud/gkehub/servicemesh_v1alpha/py.typed | 0 .../servicemesh_v1alpha}/services/__init__.py | 0 .../servicemesh_v1alpha/types/__init__.py | 8 +- .../servicemesh_v1alpha/types/servicemesh.py | 70 +- .../cloud/gkehub_v1/__init__.py | 64 +- .../cloud/gkehub_v1/gapic_metadata.json | 0 .../cloud/gkehub_v1}/py.typed | 0 .../cloud/gkehub_v1}/services/__init__.py | 0 .../gkehub_v1/services/gke_hub/__init__.py | 4 +- .../services/gke_hub/async_client.py | 440 ++- .../gkehub_v1/services/gke_hub/client.py | 515 ++- .../gkehub_v1/services/gke_hub/pagers.py | 79 +- .../services/gke_hub/transports/__init__.py | 10 +- .../services/gke_hub/transports/base.py | 246 +- .../services/gke_hub/transports/grpc.py | 216 +- .../gke_hub/transports/grpc_asyncio.py | 227 +- .../cloud/gkehub_v1/types/__init__.py | 60 +- .../cloud/gkehub_v1/types/feature.py | 112 +- .../cloud/gkehub_v1/types/membership.py | 150 +- .../cloud/gkehub_v1/types/service.py | 325 +- .../cloud/gkehub_v1alpha/__init__.py | 32 +- .../cloud/gkehub_v1alpha/gapic_metadata.json | 0 .../cloud/gkehub_v1alpha}/py.typed | 0 .../gkehub_v1alpha}/services/__init__.py | 0 .../services/gke_hub/__init__.py | 4 +- .../services/gke_hub/async_client.py | 231 +- .../gkehub_v1alpha/services/gke_hub/client.py | 289 +- .../gkehub_v1alpha/services/gke_hub/pagers.py | 45 +- .../services/gke_hub/transports/__init__.py | 10 +- .../services/gke_hub/transports/base.py | 149 +- .../services/gke_hub/transports/grpc.py | 129 +- .../gke_hub/transports/grpc_asyncio.py | 132 +- .../cloud/gkehub_v1alpha/types/__init__.py | 28 +- .../cloud/gkehub_v1alpha/types/feature.py | 120 +- .../cloud/gkehub_v1alpha/types/service.py | 150 +- .../cloud/gkehub_v1alpha2/__init__.py | 48 +- .../cloud/gkehub_v1alpha2/gapic_metadata.json | 0 .../cloud/gkehub_v1alpha2}/py.typed | 0 .../gkehub_v1alpha2}/services/__init__.py | 0 .../services/gke_hub/__init__.py | 4 +- .../services/gke_hub/async_client.py | 283 +- .../services/gke_hub/client.py | 345 +- .../services/gke_hub/pagers.py | 45 +- .../services/gke_hub/transports/__init__.py | 10 +- .../services/gke_hub/transports/base.py | 187 +- .../services/gke_hub/transports/grpc.py | 164 +- .../gke_hub/transports/grpc_asyncio.py | 172 +- .../cloud/gkehub_v1alpha2/types/__init__.py | 44 +- .../cloud/gkehub_v1alpha2/types/membership.py | 428 +-- .../cloud/gkehub_v1beta/__init__.py | 32 +- .../cloud/gkehub_v1beta/gapic_metadata.json | 0 .../cloud/gkehub_v1beta}/py.typed | 0 .../cloud/gkehub_v1beta/services/__init__.py | 0 .../services/gke_hub/__init__.py | 4 +- .../services/gke_hub/async_client.py | 231 +- .../gkehub_v1beta/services/gke_hub/client.py | 289 +- .../gkehub_v1beta/services/gke_hub/pagers.py | 45 +- .../services/gke_hub/transports/__init__.py | 10 +- .../services/gke_hub/transports/base.py | 149 +- .../services/gke_hub/transports/grpc.py | 129 +- .../gke_hub/transports/grpc_asyncio.py | 132 +- .../cloud/gkehub_v1beta/types/__init__.py | 28 +- .../cloud/gkehub_v1beta/types/feature.py | 114 +- .../cloud/gkehub_v1beta/types/service.py | 150 +- .../transports/base.py | 2 +- owl-bot-staging/v1/.coveragerc | 17 - owl-bot-staging/v1/MANIFEST.in | 2 - owl-bot-staging/v1/README.rst | 49 - owl-bot-staging/v1/docs/conf.py | 376 --- owl-bot-staging/v1/docs/index.rst | 7 - .../v1/google/cloud/gkehub/__init__.py | 83 - .../cloud/gkehub/configmanagement/__init__.py | 63 - .../gkehub/multiclusteringress/__init__.py | 21 - .../multiclusteringress_v1/types/__init__.py | 22 - owl-bot-staging/v1/mypy.ini | 3 - owl-bot-staging/v1/noxfile.py | 132 - owl-bot-staging/v1/setup.py | 53 - .../v1/tests/unit/gapic/gkehub_v1/__init__.py | 16 - .../gapic/multiclusteringress_v1/__init__.py | 16 - owl-bot-staging/v1alpha/.coveragerc | 17 - owl-bot-staging/v1alpha/MANIFEST.in | 2 - owl-bot-staging/v1alpha/README.rst | 49 - owl-bot-staging/v1alpha/docs/conf.py | 376 --- owl-bot-staging/v1alpha/docs/index.rst | 7 - .../v1alpha/google/cloud/gkehub/__init__.py | 51 - .../types/__init__.py | 22 - .../cloud/gkehub/configmanagement/__init__.py | 69 - .../google/cloud/gkehub/metering/__init__.py | 21 - .../gkehub/metering_v1alpha/types/__init__.py | 22 - .../gkehub/multiclusteringress/__init__.py | 23 - owl-bot-staging/v1alpha/mypy.ini | 3 - owl-bot-staging/v1alpha/noxfile.py | 132 - owl-bot-staging/v1alpha/setup.py | 53 - owl-bot-staging/v1alpha/tests/__init__.py | 16 - .../v1alpha/tests/unit/__init__.py | 16 - .../v1alpha/tests/unit/gapic/__init__.py | 16 - .../cloudauditlogging_v1alpha/__init__.py | 16 - .../configmanagement_v1alpha/__init__.py | 16 - .../unit/gapic/gkehub_v1alpha/__init__.py | 16 - .../unit/gapic/metering_v1alpha/__init__.py | 16 - .../multiclusteringress_v1alpha/__init__.py | 16 - .../gapic/servicemesh_v1alpha/__init__.py | 16 - owl-bot-staging/v1alpha2/.coveragerc | 17 - owl-bot-staging/v1alpha2/MANIFEST.in | 2 - owl-bot-staging/v1alpha2/README.rst | 49 - owl-bot-staging/v1alpha2/docs/conf.py | 376 --- owl-bot-staging/v1alpha2/docs/index.rst | 7 - .../v1alpha2/google/cloud/gkehub/__init__.py | 67 - .../v1alpha2/google/cloud/gkehub/py.typed | 2 - .../google/cloud/gkehub_v1alpha2/py.typed | 2 - owl-bot-staging/v1alpha2/mypy.ini | 3 - owl-bot-staging/v1alpha2/noxfile.py | 132 - owl-bot-staging/v1alpha2/setup.py | 53 - owl-bot-staging/v1alpha2/tests/__init__.py | 16 - .../v1alpha2/tests/unit/__init__.py | 16 - .../v1alpha2/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/gkehub_v1alpha2/__init__.py | 16 - owl-bot-staging/v1beta/.coveragerc | 17 - owl-bot-staging/v1beta/MANIFEST.in | 2 - owl-bot-staging/v1beta/README.rst | 49 - owl-bot-staging/v1beta/docs/conf.py | 376 --- owl-bot-staging/v1beta/docs/index.rst | 7 - .../v1beta/google/cloud/gkehub/__init__.py | 51 - .../cloud/gkehub/configmanagement/py.typed | 2 - .../gkehub/configmanagement_v1beta/py.typed | 2 - .../cloud/gkehub/metering_v1beta/py.typed | 2 - .../gkehub/metering_v1beta/types/__init__.py | 22 - .../cloud/gkehub/multiclusteringress/py.typed | 2 - .../multiclusteringress_v1beta/py.typed | 2 - .../v1beta/google/cloud/gkehub/py.typed | 2 - .../google/cloud/gkehub_v1beta/py.typed | 2 - owl-bot-staging/v1beta/mypy.ini | 3 - owl-bot-staging/v1beta/noxfile.py | 132 - owl-bot-staging/v1beta/setup.py | 53 - owl-bot-staging/v1beta/tests/__init__.py | 16 - owl-bot-staging/v1beta/tests/unit/__init__.py | 16 - .../v1beta/tests/unit/gapic/__init__.py | 16 - .../gapic/configmanagement_v1beta/__init__.py | 16 - .../unit/gapic/gkehub_v1beta/__init__.py | 16 - .../unit/gapic/metering_v1beta/__init__.py | 16 - .../multiclusteringress_v1beta/__init__.py | 16 - owl-bot-staging/v1beta1/.coveragerc | 17 - owl-bot-staging/v1beta1/MANIFEST.in | 2 - owl-bot-staging/v1beta1/README.rst | 49 - owl-bot-staging/v1beta1/docs/conf.py | 376 --- .../gke_hub_membership_service.rst | 10 - .../v1beta1/docs/gkehub_v1beta1/services.rst | 6 - .../v1beta1/docs/gkehub_v1beta1/types.rst | 7 - owl-bot-staging/v1beta1/docs/index.rst | 7 - .../v1beta1/google/cloud/gkehub/__init__.py | 73 - .../v1beta1/google/cloud/gkehub/py.typed | 2 - .../google/cloud/gkehub_v1beta1/__init__.py | 74 - .../cloud/gkehub_v1beta1/gapic_metadata.json | 103 - .../google/cloud/gkehub_v1beta1/py.typed | 2 - .../gke_hub_membership_service/__init__.py | 22 - .../async_client.py | 842 ----- .../gke_hub_membership_service/client.py | 1032 ------ .../gke_hub_membership_service/pagers.py | 140 - .../transports/__init__.py | 33 - .../transports/base.py | 273 -- .../transports/grpc.py | 468 --- .../transports/grpc_asyncio.py | 472 --- .../cloud/gkehub_v1beta1/types/__init__.py | 70 - .../cloud/gkehub_v1beta1/types/membership.py | 1075 ------- owl-bot-staging/v1beta1/mypy.ini | 3 - owl-bot-staging/v1beta1/noxfile.py | 132 - .../scripts/fixup_gkehub_v1beta1_keywords.py | 183 -- owl-bot-staging/v1beta1/setup.py | 53 - owl-bot-staging/v1beta1/tests/__init__.py | 16 - .../v1beta1/tests/unit/__init__.py | 16 - .../v1beta1/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/gkehub_v1beta1/__init__.py | 16 - .../test_gke_hub_membership_service.py | 2803 ----------------- ...ixup_cloudauditlogging_v1alpha_keywords.py | 0 .../fixup_configmanagement_v1_keywords.py | 0 ...fixup_configmanagement_v1alpha_keywords.py | 0 .../fixup_configmanagement_v1beta_keywords.py | 0 .../fixup_gkehub_v1_keywords.py | 0 .../fixup_gkehub_v1alpha2_keywords.py | 0 .../fixup_gkehub_v1alpha_keywords.py | 0 .../fixup_gkehub_v1beta_keywords.py | 0 .../fixup_metering_v1alpha_keywords.py | 0 .../fixup_metering_v1beta_keywords.py | 0 .../fixup_multiclusteringress_v1_keywords.py | 0 ...up_multiclusteringress_v1alpha_keywords.py | 0 ...xup_multiclusteringress_v1beta_keywords.py | 0 .../fixup_servicemesh_v1alpha_keywords.py | 0 .../cloudauditlogging_v1alpha}/__init__.py | 0 .../gapic/configmanagement_v1}/__init__.py | 1 - .../configmanagement_v1alpha}/__init__.py | 1 - .../configmanagement_v1beta}/__init__.py | 1 - .../unit/gapic/gkehub_v1}/__init__.py | 1 - .../unit/gapic/gkehub_v1/test_gke_hub.py | 2172 ++++++------- tests/unit/gapic/gkehub_v1alpha/__init__.py | 15 + .../unit/gapic/gkehub_v1alpha/test_gke_hub.py | 1234 ++++---- tests/unit/gapic/gkehub_v1alpha2/__init__.py | 15 + .../gapic/gkehub_v1alpha2/test_gke_hub.py | 1428 ++++----- tests/unit/gapic/gkehub_v1beta/__init__.py | 15 + .../unit/gapic/gkehub_v1beta/test_gke_hub.py | 1234 ++++---- .../test_gke_hub_membership_service.py | 6 +- tests/unit/gapic/metering_v1alpha/__init__.py | 15 + tests/unit/gapic/metering_v1beta/__init__.py | 15 + .../gapic/multiclusteringress_v1/__init__.py | 15 + .../multiclusteringress_v1alpha/__init__.py | 15 + .../multiclusteringress_v1beta/__init__.py | 15 + .../gapic/servicemesh_v1alpha/__init__.py | 15 + 304 files changed, 6465 insertions(+), 20564 deletions(-) rename {owl-bot-staging/v1alpha/docs => docs}/cloudauditlogging_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/cloudauditlogging_v1alpha/types.rst (100%) rename {owl-bot-staging/v1/docs => docs}/configmanagement_v1/services.rst (100%) rename {owl-bot-staging/v1/docs => docs}/configmanagement_v1/types.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/configmanagement_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/configmanagement_v1alpha/types.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/configmanagement_v1beta/services.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/configmanagement_v1beta/types.rst (100%) rename {owl-bot-staging/v1/docs => docs}/gkehub_v1/gke_hub.rst (100%) rename {owl-bot-staging/v1/docs => docs}/gkehub_v1/services.rst (100%) rename {owl-bot-staging/v1/docs => docs}/gkehub_v1/types.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/gkehub_v1alpha/gke_hub.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/gkehub_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/gkehub_v1alpha/types.rst (100%) rename {owl-bot-staging/v1alpha2/docs => docs}/gkehub_v1alpha2/gke_hub.rst (100%) rename {owl-bot-staging/v1alpha2/docs => docs}/gkehub_v1alpha2/services.rst (100%) rename {owl-bot-staging/v1alpha2/docs => docs}/gkehub_v1alpha2/types.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/gkehub_v1beta/gke_hub.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/gkehub_v1beta/services.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/gkehub_v1beta/types.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/metering_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/metering_v1alpha/types.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/metering_v1beta/services.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/metering_v1beta/types.rst (100%) rename {owl-bot-staging/v1/docs => docs}/multiclusteringress_v1/services.rst (100%) rename {owl-bot-staging/v1/docs => docs}/multiclusteringress_v1/types.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/multiclusteringress_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/multiclusteringress_v1alpha/types.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/multiclusteringress_v1beta/services.rst (100%) rename {owl-bot-staging/v1beta/docs => docs}/multiclusteringress_v1beta/types.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/servicemesh_v1alpha/services.rst (100%) rename {owl-bot-staging/v1alpha/docs => docs}/servicemesh_v1alpha/types.rst (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging/__init__.py (91%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging/py.typed (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py (95%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging_v1alpha/py.typed (100%) rename {owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1 => google/cloud/gkehub/cloudauditlogging_v1alpha}/services/__init__.py (100%) create mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py (86%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/configmanagement/__init__.py (58%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement/py.typed (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement_v1/__init__.py (76%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement_v1/gapic_metadata.json (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement_v1/py.typed (100%) rename {owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1 => google/cloud/gkehub/configmanagement_v1}/services/__init__.py (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement_v1/types/__init__.py (67%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/configmanagement_v1/types/configmanagement.py (66%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/configmanagement_v1alpha/__init__.py (75%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement => google/cloud/gkehub/configmanagement_v1alpha}/py.typed (100%) rename {owl-bot-staging/v1/google/cloud/gkehub_v1 => google/cloud/gkehub/configmanagement_v1alpha}/services/__init__.py (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/configmanagement_v1alpha/types/__init__.py (66%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py (66%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/configmanagement_v1beta/__init__.py (75%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha => google/cloud/gkehub/configmanagement_v1beta}/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha => google/cloud/gkehub/configmanagement_v1beta}/services/__init__.py (100%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/configmanagement_v1beta/types/__init__.py (66%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py (66%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/metering/__init__.py (95%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/metering/py.typed (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/metering_v1alpha/__init__.py (95%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/metering_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/metering_v1alpha/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha => google/cloud/gkehub/metering_v1alpha}/services/__init__.py (100%) create mode 100644 google/cloud/gkehub/metering_v1alpha/types/__init__.py rename {owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta => google/cloud/gkehub/metering_v1alpha}/types/metering.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/metering_v1beta/__init__.py (95%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/metering_v1beta/gapic_metadata.json (100%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/metering => google/cloud/gkehub/metering_v1beta}/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha => google/cloud/gkehub/metering_v1beta}/services/__init__.py (100%) create mode 100644 google/cloud/gkehub/metering_v1beta/types/__init__.py rename {owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha => google/cloud/gkehub/metering_v1beta}/types/metering.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/multiclusteringress/__init__.py (85%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/multiclusteringress/py.typed (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/multiclusteringress_v1/__init__.py (95%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub/multiclusteringress_v1/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha => google/cloud/gkehub/multiclusteringress_v1}/services/__init__.py (100%) create mode 100644 google/cloud/gkehub/multiclusteringress_v1/types/__init__.py rename {owl-bot-staging/v1/google => google}/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py (85%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta => google/cloud/gkehub/multiclusteringress_v1alpha}/__init__.py (95%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress => google/cloud/gkehub/multiclusteringress_v1alpha}/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha => google/cloud/gkehub/multiclusteringress_v1alpha}/services/__init__.py (100%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta => google/cloud/gkehub/multiclusteringress_v1alpha}/types/__init__.py (95%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py (81%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha => google/cloud/gkehub/multiclusteringress_v1beta}/__init__.py (95%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha => google/cloud/gkehub/multiclusteringress_v1beta}/py.typed (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha => google/cloud/gkehub/multiclusteringress_v1beta}/services/__init__.py (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha => google/cloud/gkehub/multiclusteringress_v1beta}/types/__init__.py (95%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh/__init__.py (86%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh/py.typed (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh_v1alpha/__init__.py (89%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh_v1alpha/py.typed (100%) rename {owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2 => google/cloud/gkehub/servicemesh_v1alpha}/services/__init__.py (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh_v1alpha/types/__init__.py (88%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py (80%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/__init__.py (71%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/gapic_metadata.json (100%) rename {owl-bot-staging/v1/google/cloud/gkehub => google/cloud/gkehub_v1}/py.typed (100%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta => google/cloud/gkehub_v1}/services/__init__.py (100%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/__init__.py (93%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/async_client.py (80%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/client.py (80%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/pagers.py (86%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha => google/cloud/gkehub_v1}/services/gke_hub/transports/__init__.py (82%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/transports/base.py (56%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/transports/grpc.py (78%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py (77%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/types/__init__.py (64%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/types/feature.py (79%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/types/membership.py (78%) rename {owl-bot-staging/v1/google => google}/cloud/gkehub_v1/types/service.py (79%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/__init__.py (76%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/gapic_metadata.json (100%) rename {owl-bot-staging/v1/google/cloud/gkehub_v1 => google/cloud/gkehub_v1alpha}/py.typed (100%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta => google/cloud/gkehub_v1alpha}/services/__init__.py (100%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/__init__.py (93%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/async_client.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/client.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/pagers.py (86%) rename {owl-bot-staging/v1/google/cloud/gkehub_v1 => google/cloud/gkehub_v1alpha}/services/gke_hub/transports/__init__.py (82%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py (64%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/types/__init__.py (73%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/types/feature.py (81%) rename {owl-bot-staging/v1alpha/google => google}/cloud/gkehub_v1alpha/types/service.py (79%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/__init__.py (74%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub => google/cloud/gkehub_v1alpha2}/py.typed (100%) rename {owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta => google/cloud/gkehub_v1alpha2}/services/__init__.py (100%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py (93%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py (79%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/client.py (80%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py (85%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py (82%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py (60%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py (79%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py (78%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/types/__init__.py (66%) rename {owl-bot-staging/v1alpha2/google => google}/cloud/gkehub_v1alpha2/types/membership.py (77%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/__init__.py (76%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/gapic_metadata.json (100%) rename {owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha => google/cloud/gkehub_v1beta}/py.typed (100%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/__init__.py (100%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/__init__.py (93%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/async_client.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/client.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/pagers.py (86%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py (82%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/transports/base.py (64%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py (81%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/types/__init__.py (73%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/types/feature.py (80%) rename {owl-bot-staging/v1beta/google => google}/cloud/gkehub_v1beta/types/service.py (79%) delete mode 100644 owl-bot-staging/v1/.coveragerc delete mode 100644 owl-bot-staging/v1/MANIFEST.in delete mode 100644 owl-bot-staging/v1/README.rst delete mode 100644 owl-bot-staging/v1/docs/conf.py delete mode 100644 owl-bot-staging/v1/docs/index.rst delete mode 100644 owl-bot-staging/v1/google/cloud/gkehub/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py delete mode 100644 owl-bot-staging/v1/mypy.ini delete mode 100644 owl-bot-staging/v1/noxfile.py delete mode 100644 owl-bot-staging/v1/setup.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py delete mode 100644 owl-bot-staging/v1alpha/.coveragerc delete mode 100644 owl-bot-staging/v1alpha/MANIFEST.in delete mode 100644 owl-bot-staging/v1alpha/README.rst delete mode 100644 owl-bot-staging/v1alpha/docs/conf.py delete mode 100644 owl-bot-staging/v1alpha/docs/index.rst delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py delete mode 100644 owl-bot-staging/v1alpha/mypy.ini delete mode 100644 owl-bot-staging/v1alpha/noxfile.py delete mode 100644 owl-bot-staging/v1alpha/setup.py delete mode 100644 owl-bot-staging/v1alpha/tests/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha2/.coveragerc delete mode 100644 owl-bot-staging/v1alpha2/MANIFEST.in delete mode 100644 owl-bot-staging/v1alpha2/README.rst delete mode 100644 owl-bot-staging/v1alpha2/docs/conf.py delete mode 100644 owl-bot-staging/v1alpha2/docs/index.rst delete mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py delete mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed delete mode 100644 owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed delete mode 100644 owl-bot-staging/v1alpha2/mypy.ini delete mode 100644 owl-bot-staging/v1alpha2/noxfile.py delete mode 100644 owl-bot-staging/v1alpha2/setup.py delete mode 100644 owl-bot-staging/v1alpha2/tests/__init__.py delete mode 100644 owl-bot-staging/v1alpha2/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py delete mode 100644 owl-bot-staging/v1beta/.coveragerc delete mode 100644 owl-bot-staging/v1beta/MANIFEST.in delete mode 100644 owl-bot-staging/v1beta/README.rst delete mode 100644 owl-bot-staging/v1beta/docs/conf.py delete mode 100644 owl-bot-staging/v1beta/docs/index.rst delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub/py.typed delete mode 100644 owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed delete mode 100644 owl-bot-staging/v1beta/mypy.ini delete mode 100644 owl-bot-staging/v1beta/noxfile.py delete mode 100644 owl-bot-staging/v1beta/setup.py delete mode 100644 owl-bot-staging/v1beta/tests/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py delete mode 100644 owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py delete mode 100644 owl-bot-staging/v1beta1/.coveragerc delete mode 100644 owl-bot-staging/v1beta1/MANIFEST.in delete mode 100644 owl-bot-staging/v1beta1/README.rst delete mode 100644 owl-bot-staging/v1beta1/docs/conf.py delete mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst delete mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst delete mode 100644 owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst delete mode 100644 owl-bot-staging/v1beta1/docs/index.rst delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py delete mode 100644 owl-bot-staging/v1beta1/mypy.ini delete mode 100644 owl-bot-staging/v1beta1/noxfile.py delete mode 100644 owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py delete mode 100644 owl-bot-staging/v1beta1/setup.py delete mode 100644 owl-bot-staging/v1beta1/tests/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_cloudauditlogging_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1/scripts => scripts}/fixup_configmanagement_v1_keywords.py (100%) rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_configmanagement_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1beta/scripts => scripts}/fixup_configmanagement_v1beta_keywords.py (100%) rename {owl-bot-staging/v1/scripts => scripts}/fixup_gkehub_v1_keywords.py (100%) rename {owl-bot-staging/v1alpha2/scripts => scripts}/fixup_gkehub_v1alpha2_keywords.py (100%) rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_gkehub_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1beta/scripts => scripts}/fixup_gkehub_v1beta_keywords.py (100%) rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_metering_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1beta/scripts => scripts}/fixup_metering_v1beta_keywords.py (100%) rename {owl-bot-staging/v1/scripts => scripts}/fixup_multiclusteringress_v1_keywords.py (100%) rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_multiclusteringress_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1beta/scripts => scripts}/fixup_multiclusteringress_v1beta_keywords.py (100%) rename {owl-bot-staging/v1alpha/scripts => scripts}/fixup_servicemesh_v1alpha_keywords.py (100%) rename {owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services => tests/unit/gapic/cloudauditlogging_v1alpha}/__init__.py (100%) rename {owl-bot-staging/v1/tests/unit => tests/unit/gapic/configmanagement_v1}/__init__.py (99%) rename {owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1 => tests/unit/gapic/configmanagement_v1alpha}/__init__.py (99%) rename {owl-bot-staging/v1/tests/unit/gapic => tests/unit/gapic/configmanagement_v1beta}/__init__.py (99%) rename {owl-bot-staging/v1/tests => tests/unit/gapic/gkehub_v1}/__init__.py (99%) rename {owl-bot-staging/v1/tests => tests}/unit/gapic/gkehub_v1/test_gke_hub.py (64%) create mode 100644 tests/unit/gapic/gkehub_v1alpha/__init__.py rename {owl-bot-staging/v1alpha/tests => tests}/unit/gapic/gkehub_v1alpha/test_gke_hub.py (66%) create mode 100644 tests/unit/gapic/gkehub_v1alpha2/__init__.py rename {owl-bot-staging/v1alpha2/tests => tests}/unit/gapic/gkehub_v1alpha2/test_gke_hub.py (66%) create mode 100644 tests/unit/gapic/gkehub_v1beta/__init__.py rename {owl-bot-staging/v1beta/tests => tests}/unit/gapic/gkehub_v1beta/test_gke_hub.py (66%) create mode 100644 tests/unit/gapic/metering_v1alpha/__init__.py create mode 100644 tests/unit/gapic/metering_v1beta/__init__.py create mode 100644 tests/unit/gapic/multiclusteringress_v1/__init__.py create mode 100644 tests/unit/gapic/multiclusteringress_v1alpha/__init__.py create mode 100644 tests/unit/gapic/multiclusteringress_v1beta/__init__.py create mode 100644 tests/unit/gapic/servicemesh_v1alpha/__init__.py diff --git a/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst b/docs/cloudauditlogging_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/services.rst rename to docs/cloudauditlogging_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst b/docs/cloudauditlogging_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/cloudauditlogging_v1alpha/types.rst rename to docs/cloudauditlogging_v1alpha/types.rst diff --git a/owl-bot-staging/v1/docs/configmanagement_v1/services.rst b/docs/configmanagement_v1/services.rst similarity index 100% rename from owl-bot-staging/v1/docs/configmanagement_v1/services.rst rename to docs/configmanagement_v1/services.rst diff --git a/owl-bot-staging/v1/docs/configmanagement_v1/types.rst b/docs/configmanagement_v1/types.rst similarity index 100% rename from owl-bot-staging/v1/docs/configmanagement_v1/types.rst rename to docs/configmanagement_v1/types.rst diff --git a/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst b/docs/configmanagement_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/services.rst rename to docs/configmanagement_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst b/docs/configmanagement_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/configmanagement_v1alpha/types.rst rename to docs/configmanagement_v1alpha/types.rst diff --git a/owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst b/docs/configmanagement_v1beta/services.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/configmanagement_v1beta/services.rst rename to docs/configmanagement_v1beta/services.rst diff --git a/owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst b/docs/configmanagement_v1beta/types.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/configmanagement_v1beta/types.rst rename to docs/configmanagement_v1beta/types.rst diff --git a/owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst b/docs/gkehub_v1/gke_hub.rst similarity index 100% rename from owl-bot-staging/v1/docs/gkehub_v1/gke_hub.rst rename to docs/gkehub_v1/gke_hub.rst diff --git a/owl-bot-staging/v1/docs/gkehub_v1/services.rst b/docs/gkehub_v1/services.rst similarity index 100% rename from owl-bot-staging/v1/docs/gkehub_v1/services.rst rename to docs/gkehub_v1/services.rst diff --git a/owl-bot-staging/v1/docs/gkehub_v1/types.rst b/docs/gkehub_v1/types.rst similarity index 100% rename from owl-bot-staging/v1/docs/gkehub_v1/types.rst rename to docs/gkehub_v1/types.rst diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst b/docs/gkehub_v1alpha/gke_hub.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/gkehub_v1alpha/gke_hub.rst rename to docs/gkehub_v1alpha/gke_hub.rst diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst b/docs/gkehub_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/gkehub_v1alpha/services.rst rename to docs/gkehub_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst b/docs/gkehub_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/gkehub_v1alpha/types.rst rename to docs/gkehub_v1alpha/types.rst diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst b/docs/gkehub_v1alpha2/gke_hub.rst similarity index 100% rename from owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/gke_hub.rst rename to docs/gkehub_v1alpha2/gke_hub.rst diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst b/docs/gkehub_v1alpha2/services.rst similarity index 100% rename from owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/services.rst rename to docs/gkehub_v1alpha2/services.rst diff --git a/owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst b/docs/gkehub_v1alpha2/types.rst similarity index 100% rename from owl-bot-staging/v1alpha2/docs/gkehub_v1alpha2/types.rst rename to docs/gkehub_v1alpha2/types.rst diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst b/docs/gkehub_v1beta/gke_hub.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/gkehub_v1beta/gke_hub.rst rename to docs/gkehub_v1beta/gke_hub.rst diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst b/docs/gkehub_v1beta/services.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/gkehub_v1beta/services.rst rename to docs/gkehub_v1beta/services.rst diff --git a/owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst b/docs/gkehub_v1beta/types.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/gkehub_v1beta/types.rst rename to docs/gkehub_v1beta/types.rst diff --git a/owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst b/docs/metering_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/metering_v1alpha/services.rst rename to docs/metering_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst b/docs/metering_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/metering_v1alpha/types.rst rename to docs/metering_v1alpha/types.rst diff --git a/owl-bot-staging/v1beta/docs/metering_v1beta/services.rst b/docs/metering_v1beta/services.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/metering_v1beta/services.rst rename to docs/metering_v1beta/services.rst diff --git a/owl-bot-staging/v1beta/docs/metering_v1beta/types.rst b/docs/metering_v1beta/types.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/metering_v1beta/types.rst rename to docs/metering_v1beta/types.rst diff --git a/owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst b/docs/multiclusteringress_v1/services.rst similarity index 100% rename from owl-bot-staging/v1/docs/multiclusteringress_v1/services.rst rename to docs/multiclusteringress_v1/services.rst diff --git a/owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst b/docs/multiclusteringress_v1/types.rst similarity index 100% rename from owl-bot-staging/v1/docs/multiclusteringress_v1/types.rst rename to docs/multiclusteringress_v1/types.rst diff --git a/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst b/docs/multiclusteringress_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/services.rst rename to docs/multiclusteringress_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst b/docs/multiclusteringress_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/multiclusteringress_v1alpha/types.rst rename to docs/multiclusteringress_v1alpha/types.rst diff --git a/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst b/docs/multiclusteringress_v1beta/services.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/services.rst rename to docs/multiclusteringress_v1beta/services.rst diff --git a/owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst b/docs/multiclusteringress_v1beta/types.rst similarity index 100% rename from owl-bot-staging/v1beta/docs/multiclusteringress_v1beta/types.rst rename to docs/multiclusteringress_v1beta/types.rst diff --git a/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst b/docs/servicemesh_v1alpha/services.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/services.rst rename to docs/servicemesh_v1alpha/services.rst diff --git a/owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst b/docs/servicemesh_v1alpha/types.rst similarity index 100% rename from owl-bot-staging/v1alpha/docs/servicemesh_v1alpha/types.rst rename to docs/servicemesh_v1alpha/types.rst diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py b/google/cloud/gkehub/cloudauditlogging/__init__.py similarity index 91% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py rename to google/cloud/gkehub/cloudauditlogging/__init__.py index d2889ec..838c1fb 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/__init__.py +++ b/google/cloud/gkehub/cloudauditlogging/__init__.py @@ -15,7 +15,8 @@ # -from google.cloud.gkehub.cloudauditlogging_v1alpha.types.cloudauditlogging import FeatureSpec - -__all__ = ('FeatureSpec', +from google.cloud.gkehub.cloudauditlogging_v1alpha.types.cloudauditlogging import ( + FeatureSpec, ) + +__all__ = ("FeatureSpec",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed b/google/cloud/gkehub/cloudauditlogging/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging/py.typed rename to google/cloud/gkehub/cloudauditlogging/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py similarity index 95% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py rename to google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py index 9d603d2..f7a66d1 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py +++ b/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py @@ -17,6 +17,4 @@ from .types.cloudauditlogging import FeatureSpec -__all__ = ( -'FeatureSpec', -) +__all__ = ("FeatureSpec",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json b/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json rename to google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed b/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed rename to google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/services/__init__.py rename to google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py new file mode 100644 index 0000000..9e00155 --- /dev/null +++ b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .cloudauditlogging import FeatureSpec + +__all__ = ("FeatureSpec",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py similarity index 86% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py rename to google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py index 5cfd9ce..0f3d3eb 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py +++ b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py @@ -17,10 +17,7 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.cloudauditlogging.v1alpha', - manifest={ - 'FeatureSpec', - }, + package="google.cloud.gkehub.cloudauditlogging.v1alpha", manifest={"FeatureSpec",}, ) @@ -38,10 +35,7 @@ class FeatureSpec(proto.Message): Anthos customer.) """ - allowlisted_service_accounts = proto.RepeatedField( - proto.STRING, - number=1, - ) + allowlisted_service_accounts = proto.RepeatedField(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py b/google/cloud/gkehub/configmanagement/__init__.py similarity index 58% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py rename to google/cloud/gkehub/configmanagement/__init__.py index f19d1b8..52879c2 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/__init__.py +++ b/google/cloud/gkehub/configmanagement/__init__.py @@ -15,55 +15,100 @@ # -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzConfig -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import BinauthzVersion -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSync -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncDeploymentState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ConfigSyncVersion -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ErrorResource -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GatekeeperDeploymentState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + BinauthzConfig, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + BinauthzState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + BinauthzVersion, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + ConfigSync, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + ConfigSyncDeploymentState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + ConfigSyncState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + ConfigSyncVersion, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + ErrorResource, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + GatekeeperDeploymentState, +) from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GitConfig -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GroupVersionKind -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerConfig -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerDeploymentState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import HierarchyControllerVersion -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import InstallError -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import MembershipSpec -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import MembershipState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import OperatorState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyController -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyControllerState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import PolicyControllerVersion +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + GroupVersionKind, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + HierarchyControllerConfig, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + HierarchyControllerDeploymentState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + HierarchyControllerState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + HierarchyControllerVersion, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + InstallError, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + MembershipSpec, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + MembershipState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + OperatorState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + PolicyController, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + PolicyControllerState, +) +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + PolicyControllerVersion, +) from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncError from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import DeploymentState +from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( + DeploymentState, +) -__all__ = ('BinauthzConfig', - 'BinauthzState', - 'BinauthzVersion', - 'ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', +__all__ = ( + "BinauthzConfig", + "BinauthzState", + "BinauthzVersion", + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", + "DeploymentState", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed b/google/cloud/gkehub/configmanagement/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement/py.typed rename to google/cloud/gkehub/configmanagement/py.typed diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py b/google/cloud/gkehub/configmanagement_v1/__init__.py similarity index 76% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py rename to google/cloud/gkehub/configmanagement_v1/__init__.py index ffa35d2..511def9 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1/__init__.py @@ -39,26 +39,26 @@ from .types.configmanagement import DeploymentState __all__ = ( -'ConfigSync', -'ConfigSyncDeploymentState', -'ConfigSyncState', -'ConfigSyncVersion', -'DeploymentState', -'ErrorResource', -'GatekeeperDeploymentState', -'GitConfig', -'GroupVersionKind', -'HierarchyControllerConfig', -'HierarchyControllerDeploymentState', -'HierarchyControllerState', -'HierarchyControllerVersion', -'InstallError', -'MembershipSpec', -'MembershipState', -'OperatorState', -'PolicyController', -'PolicyControllerState', -'PolicyControllerVersion', -'SyncError', -'SyncState', + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "DeploymentState", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json b/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json rename to google/cloud/gkehub/configmanagement_v1/gapic_metadata.json diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed b/google/cloud/gkehub/configmanagement_v1/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/py.typed rename to google/cloud/gkehub/configmanagement_v1/py.typed diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py b/google/cloud/gkehub/configmanagement_v1/services/__init__.py similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py rename to google/cloud/gkehub/configmanagement_v1/services/__init__.py diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py b/google/cloud/gkehub/configmanagement_v1/types/__init__.py similarity index 67% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py rename to google/cloud/gkehub/configmanagement_v1/types/__init__.py index 784db8b..d6d417c 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1/types/__init__.py @@ -39,26 +39,26 @@ ) __all__ = ( - 'ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", + "DeploymentState", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py similarity index 66% rename from owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py rename to google/cloud/gkehub/configmanagement_v1/types/configmanagement.py index 6cbd43e..148af42 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py +++ b/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py @@ -19,30 +19,30 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.configmanagement.v1', + package="google.cloud.gkehub.configmanagement.v1", manifest={ - 'DeploymentState', - 'MembershipState', - 'MembershipSpec', - 'ConfigSync', - 'GitConfig', - 'PolicyController', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerVersion', - 'HierarchyControllerState', - 'OperatorState', - 'InstallError', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ConfigSyncDeploymentState', - 'SyncState', - 'SyncError', - 'ErrorResource', - 'GroupVersionKind', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'GatekeeperDeploymentState', + "DeploymentState", + "MembershipState", + "MembershipSpec", + "ConfigSync", + "GitConfig", + "PolicyController", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerVersion", + "HierarchyControllerState", + "OperatorState", + "InstallError", + "ConfigSyncState", + "ConfigSyncVersion", + "ConfigSyncDeploymentState", + "SyncState", + "SyncError", + "ErrorResource", + "GroupVersionKind", + "PolicyControllerState", + "PolicyControllerVersion", + "GatekeeperDeploymentState", }, ) @@ -82,34 +82,15 @@ class MembershipState(proto.Message): Hierarchy Controller status """ - cluster_name = proto.Field( - proto.STRING, - number=1, - ) - membership_spec = proto.Field( - proto.MESSAGE, - number=2, - message='MembershipSpec', - ) - operator_state = proto.Field( - proto.MESSAGE, - number=3, - message='OperatorState', - ) - config_sync_state = proto.Field( - proto.MESSAGE, - number=4, - message='ConfigSyncState', - ) + cluster_name = proto.Field(proto.STRING, number=1,) + membership_spec = proto.Field(proto.MESSAGE, number=2, message="MembershipSpec",) + operator_state = proto.Field(proto.MESSAGE, number=3, message="OperatorState",) + config_sync_state = proto.Field(proto.MESSAGE, number=4, message="ConfigSyncState",) policy_controller_state = proto.Field( - proto.MESSAGE, - number=5, - message='PolicyControllerState', + proto.MESSAGE, number=5, message="PolicyControllerState", ) hierarchy_controller_state = proto.Field( - proto.MESSAGE, - number=7, - message='HierarchyControllerState', + proto.MESSAGE, number=7, message="HierarchyControllerState", ) @@ -130,25 +111,14 @@ class MembershipSpec(proto.Message): Version of ACM installed. """ - config_sync = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSync', - ) + config_sync = proto.Field(proto.MESSAGE, number=1, message="ConfigSync",) policy_controller = proto.Field( - proto.MESSAGE, - number=2, - message='PolicyController', + proto.MESSAGE, number=2, message="PolicyController", ) hierarchy_controller = proto.Field( - proto.MESSAGE, - number=4, - message='HierarchyControllerConfig', - ) - version = proto.Field( - proto.STRING, - number=10, + proto.MESSAGE, number=4, message="HierarchyControllerConfig", ) + version = proto.Field(proto.STRING, number=10,) class ConfigSync(proto.Message): @@ -161,15 +131,8 @@ class ConfigSync(proto.Message): in “hierarchical” or “unstructured” mode. """ - git = proto.Field( - proto.MESSAGE, - number=7, - message='GitConfig', - ) - source_format = proto.Field( - proto.STRING, - number=8, - ) + git = proto.Field(proto.MESSAGE, number=7, message="GitConfig",) + source_format = proto.Field(proto.STRING, number=8,) class GitConfig(proto.Message): @@ -202,38 +165,14 @@ class GitConfig(proto.Message): is gcpServiceAccount. """ - sync_repo = proto.Field( - proto.STRING, - number=1, - ) - sync_branch = proto.Field( - proto.STRING, - number=2, - ) - policy_dir = proto.Field( - proto.STRING, - number=3, - ) - sync_wait_secs = proto.Field( - proto.INT64, - number=4, - ) - sync_rev = proto.Field( - proto.STRING, - number=5, - ) - secret_type = proto.Field( - proto.STRING, - number=6, - ) - https_proxy = proto.Field( - proto.STRING, - number=7, - ) - gcp_service_account_email = proto.Field( - proto.STRING, - number=8, - ) + sync_repo = proto.Field(proto.STRING, number=1,) + sync_branch = proto.Field(proto.STRING, number=2,) + policy_dir = proto.Field(proto.STRING, number=3,) + sync_wait_secs = proto.Field(proto.INT64, number=4,) + sync_rev = proto.Field(proto.STRING, number=5,) + secret_type = proto.Field(proto.STRING, number=6,) + https_proxy = proto.Field(proto.STRING, number=7,) + gcp_service_account_email = proto.Field(proto.STRING, number=8,) class PolicyController(proto.Message): @@ -262,32 +201,12 @@ class PolicyController(proto.Message): Logs all denies and dry run failures. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - template_library_installed = proto.Field( - proto.BOOL, - number=2, - optional=True, - ) - audit_interval_seconds = proto.Field( - proto.INT64, - number=3, - optional=True, - ) - exemptable_namespaces = proto.RepeatedField( - proto.STRING, - number=4, - ) - referential_rules_enabled = proto.Field( - proto.BOOL, - number=5, - ) - log_denies_enabled = proto.Field( - proto.BOOL, - number=6, - ) + enabled = proto.Field(proto.BOOL, number=1,) + template_library_installed = proto.Field(proto.BOOL, number=2, optional=True,) + audit_interval_seconds = proto.Field(proto.INT64, number=3, optional=True,) + exemptable_namespaces = proto.RepeatedField(proto.STRING, number=4,) + referential_rules_enabled = proto.Field(proto.BOOL, number=5,) + log_denies_enabled = proto.Field(proto.BOOL, number=6,) class HierarchyControllerConfig(proto.Message): @@ -304,18 +223,9 @@ class HierarchyControllerConfig(proto.Message): enabled in this cluster. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - enable_pod_tree_labels = proto.Field( - proto.BOOL, - number=2, - ) - enable_hierarchical_resource_quota = proto.Field( - proto.BOOL, - number=3, - ) + enabled = proto.Field(proto.BOOL, number=1,) + enable_pod_tree_labels = proto.Field(proto.BOOL, number=2,) + enable_hierarchical_resource_quota = proto.Field(proto.BOOL, number=3,) class HierarchyControllerDeploymentState(proto.Message): @@ -329,16 +239,8 @@ class HierarchyControllerDeploymentState(proto.Message): extension (e.g. v0.7.0-hc.1) """ - hnc = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - extension = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) + hnc = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + extension = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) class HierarchyControllerVersion(proto.Message): @@ -350,14 +252,8 @@ class HierarchyControllerVersion(proto.Message): Version for Hierarchy Controller extension """ - hnc = proto.Field( - proto.STRING, - number=1, - ) - extension = proto.Field( - proto.STRING, - number=2, - ) + hnc = proto.Field(proto.STRING, number=1,) + extension = proto.Field(proto.STRING, number=2,) class HierarchyControllerState(proto.Message): @@ -370,14 +266,10 @@ class HierarchyControllerState(proto.Message): """ version = proto.Field( - proto.MESSAGE, - number=1, - message='HierarchyControllerVersion', + proto.MESSAGE, number=1, message="HierarchyControllerVersion", ) state = proto.Field( - proto.MESSAGE, - number=2, - message='HierarchyControllerDeploymentState', + proto.MESSAGE, number=2, message="HierarchyControllerDeploymentState", ) @@ -392,20 +284,9 @@ class OperatorState(proto.Message): Install errors. """ - version = proto.Field( - proto.STRING, - number=1, - ) - deployment_state = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='InstallError', - ) + version = proto.Field(proto.STRING, number=1,) + deployment_state = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + errors = proto.RepeatedField(proto.MESSAGE, number=3, message="InstallError",) class InstallError(proto.Message): @@ -416,10 +297,7 @@ class InstallError(proto.Message): message """ - error_message = proto.Field( - proto.STRING, - number=1, - ) + error_message = proto.Field(proto.STRING, number=1,) class ConfigSyncState(proto.Message): @@ -436,21 +314,11 @@ class ConfigSyncState(proto.Message): configs to a cluster """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSyncVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="ConfigSyncVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='ConfigSyncDeploymentState', - ) - sync_state = proto.Field( - proto.MESSAGE, - number=3, - message='SyncState', + proto.MESSAGE, number=2, message="ConfigSyncDeploymentState", ) + sync_state = proto.Field(proto.MESSAGE, number=3, message="SyncState",) class ConfigSyncVersion(proto.Message): @@ -474,30 +342,12 @@ class ConfigSyncVersion(proto.Message): in root-reconciler pod """ - importer = proto.Field( - proto.STRING, - number=1, - ) - syncer = proto.Field( - proto.STRING, - number=2, - ) - git_sync = proto.Field( - proto.STRING, - number=3, - ) - monitor = proto.Field( - proto.STRING, - number=4, - ) - reconciler_manager = proto.Field( - proto.STRING, - number=5, - ) - root_reconciler = proto.Field( - proto.STRING, - number=6, - ) + importer = proto.Field(proto.STRING, number=1,) + syncer = proto.Field(proto.STRING, number=2,) + git_sync = proto.Field(proto.STRING, number=3,) + monitor = proto.Field(proto.STRING, number=4,) + reconciler_manager = proto.Field(proto.STRING, number=5,) + root_reconciler = proto.Field(proto.STRING, number=6,) class ConfigSyncDeploymentState(proto.Message): @@ -517,36 +367,12 @@ class ConfigSyncDeploymentState(proto.Message): Deployment state of root-reconciler """ - importer = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - syncer = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - git_sync = proto.Field( - proto.ENUM, - number=3, - enum='DeploymentState', - ) - monitor = proto.Field( - proto.ENUM, - number=4, - enum='DeploymentState', - ) - reconciler_manager = proto.Field( - proto.ENUM, - number=5, - enum='DeploymentState', - ) - root_reconciler = proto.Field( - proto.ENUM, - number=6, - enum='DeploymentState', - ) + importer = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + syncer = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + git_sync = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) + monitor = proto.Field(proto.ENUM, number=4, enum="DeploymentState",) + reconciler_manager = proto.Field(proto.ENUM, number=5, enum="DeploymentState",) + root_reconciler = proto.Field(proto.ENUM, number=6, enum="DeploymentState",) class SyncState(proto.Message): @@ -575,6 +401,7 @@ class SyncState(proto.Message): errors, although it is unlikely for that many errors to simultaneously exist. """ + class SyncCode(proto.Enum): r"""An enum representing an ACM's status syncing configs to a cluster @@ -588,37 +415,15 @@ class SyncCode(proto.Enum): UNAUTHORIZED = 6 UNREACHABLE = 7 - source_token = proto.Field( - proto.STRING, - number=1, - ) - import_token = proto.Field( - proto.STRING, - number=2, - ) - sync_token = proto.Field( - proto.STRING, - number=3, - ) - last_sync = proto.Field( - proto.STRING, - number=4, - ) + source_token = proto.Field(proto.STRING, number=1,) + import_token = proto.Field(proto.STRING, number=2,) + sync_token = proto.Field(proto.STRING, number=3,) + last_sync = proto.Field(proto.STRING, number=4,) last_sync_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - code = proto.Field( - proto.ENUM, - number=5, - enum=SyncCode, - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=6, - message='SyncError', + proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) + code = proto.Field(proto.ENUM, number=5, enum=SyncCode,) + errors = proto.RepeatedField(proto.MESSAGE, number=6, message="SyncError",) class SyncError(proto.Message): @@ -635,18 +440,10 @@ class SyncError(proto.Message): error, if any """ - code = proto.Field( - proto.STRING, - number=1, - ) - error_message = proto.Field( - proto.STRING, - number=2, - ) + code = proto.Field(proto.STRING, number=1,) + error_message = proto.Field(proto.STRING, number=2,) error_resources = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ErrorResource', + proto.MESSAGE, number=3, message="ErrorResource", ) @@ -668,23 +465,10 @@ class ErrorResource(proto.Message): causing an error """ - source_path = proto.Field( - proto.STRING, - number=1, - ) - resource_name = proto.Field( - proto.STRING, - number=2, - ) - resource_namespace = proto.Field( - proto.STRING, - number=3, - ) - resource_gvk = proto.Field( - proto.MESSAGE, - number=4, - message='GroupVersionKind', - ) + source_path = proto.Field(proto.STRING, number=1,) + resource_name = proto.Field(proto.STRING, number=2,) + resource_namespace = proto.Field(proto.STRING, number=3,) + resource_gvk = proto.Field(proto.MESSAGE, number=4, message="GroupVersionKind",) class GroupVersionKind(proto.Message): @@ -698,18 +482,9 @@ class GroupVersionKind(proto.Message): Kubernetes Kind """ - group = proto.Field( - proto.STRING, - number=1, - ) - version = proto.Field( - proto.STRING, - number=2, - ) - kind = proto.Field( - proto.STRING, - number=3, - ) + group = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) + kind = proto.Field(proto.STRING, number=3,) class PolicyControllerState(proto.Message): @@ -723,15 +498,9 @@ class PolicyControllerState(proto.Message): installation. """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='PolicyControllerVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="PolicyControllerVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='GatekeeperDeploymentState', + proto.MESSAGE, number=2, message="GatekeeperDeploymentState", ) @@ -743,10 +512,7 @@ class PolicyControllerVersion(proto.Message): ACM version, git tag, build number. """ - version = proto.Field( - proto.STRING, - number=1, - ) + version = proto.Field(proto.STRING, number=1,) class GatekeeperDeploymentState(proto.Message): @@ -759,15 +525,9 @@ class GatekeeperDeploymentState(proto.Message): """ gatekeeper_controller_manager_state = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - gatekeeper_audit = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', + proto.ENUM, number=1, enum="DeploymentState", ) + gatekeeper_audit = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/__init__.py similarity index 75% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py rename to google/cloud/gkehub/configmanagement_v1alpha/__init__.py index 03dba4e..07c8615 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1alpha/__init__.py @@ -42,29 +42,29 @@ from .types.configmanagement import DeploymentState __all__ = ( -'BinauthzConfig', -'BinauthzState', -'BinauthzVersion', -'ConfigSync', -'ConfigSyncDeploymentState', -'ConfigSyncState', -'ConfigSyncVersion', -'DeploymentState', -'ErrorResource', -'GatekeeperDeploymentState', -'GitConfig', -'GroupVersionKind', -'HierarchyControllerConfig', -'HierarchyControllerDeploymentState', -'HierarchyControllerState', -'HierarchyControllerVersion', -'InstallError', -'MembershipSpec', -'MembershipState', -'OperatorState', -'PolicyController', -'PolicyControllerState', -'PolicyControllerVersion', -'SyncError', -'SyncState', + "BinauthzConfig", + "BinauthzState", + "BinauthzVersion", + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "DeploymentState", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json b/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json rename to google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed b/google/cloud/gkehub/configmanagement_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/py.typed rename to google/cloud/gkehub/configmanagement_v1alpha/py.typed diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/__init__.py rename to google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py similarity index 66% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py rename to google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py index 91fc337..b65646c 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py @@ -42,29 +42,29 @@ ) __all__ = ( - 'BinauthzConfig', - 'BinauthzState', - 'BinauthzVersion', - 'ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', + "BinauthzConfig", + "BinauthzState", + "BinauthzVersion", + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", + "DeploymentState", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py similarity index 66% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py rename to google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py index afc4755..22bf2c9 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py +++ b/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py @@ -19,33 +19,33 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.configmanagement.v1alpha', + package="google.cloud.gkehub.configmanagement.v1alpha", manifest={ - 'DeploymentState', - 'MembershipState', - 'MembershipSpec', - 'ConfigSync', - 'GitConfig', - 'PolicyController', - 'BinauthzConfig', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerVersion', - 'HierarchyControllerState', - 'OperatorState', - 'InstallError', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ConfigSyncDeploymentState', - 'SyncState', - 'SyncError', - 'ErrorResource', - 'GroupVersionKind', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'BinauthzState', - 'BinauthzVersion', - 'GatekeeperDeploymentState', + "DeploymentState", + "MembershipState", + "MembershipSpec", + "ConfigSync", + "GitConfig", + "PolicyController", + "BinauthzConfig", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerVersion", + "HierarchyControllerState", + "OperatorState", + "InstallError", + "ConfigSyncState", + "ConfigSyncVersion", + "ConfigSyncDeploymentState", + "SyncState", + "SyncError", + "ErrorResource", + "GroupVersionKind", + "PolicyControllerState", + "PolicyControllerVersion", + "BinauthzState", + "BinauthzVersion", + "GatekeeperDeploymentState", }, ) @@ -87,39 +87,16 @@ class MembershipState(proto.Message): Hierarchy Controller status """ - cluster_name = proto.Field( - proto.STRING, - number=1, - ) - membership_spec = proto.Field( - proto.MESSAGE, - number=2, - message='MembershipSpec', - ) - operator_state = proto.Field( - proto.MESSAGE, - number=3, - message='OperatorState', - ) - config_sync_state = proto.Field( - proto.MESSAGE, - number=4, - message='ConfigSyncState', - ) + cluster_name = proto.Field(proto.STRING, number=1,) + membership_spec = proto.Field(proto.MESSAGE, number=2, message="MembershipSpec",) + operator_state = proto.Field(proto.MESSAGE, number=3, message="OperatorState",) + config_sync_state = proto.Field(proto.MESSAGE, number=4, message="ConfigSyncState",) policy_controller_state = proto.Field( - proto.MESSAGE, - number=5, - message='PolicyControllerState', - ) - binauthz_state = proto.Field( - proto.MESSAGE, - number=6, - message='BinauthzState', + proto.MESSAGE, number=5, message="PolicyControllerState", ) + binauthz_state = proto.Field(proto.MESSAGE, number=6, message="BinauthzState",) hierarchy_controller_state = proto.Field( - proto.MESSAGE, - number=7, - message='HierarchyControllerState', + proto.MESSAGE, number=7, message="HierarchyControllerState", ) @@ -142,30 +119,15 @@ class MembershipSpec(proto.Message): Version of ACM installed. """ - config_sync = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSync', - ) + config_sync = proto.Field(proto.MESSAGE, number=1, message="ConfigSync",) policy_controller = proto.Field( - proto.MESSAGE, - number=2, - message='PolicyController', - ) - binauthz = proto.Field( - proto.MESSAGE, - number=3, - message='BinauthzConfig', + proto.MESSAGE, number=2, message="PolicyController", ) + binauthz = proto.Field(proto.MESSAGE, number=3, message="BinauthzConfig",) hierarchy_controller = proto.Field( - proto.MESSAGE, - number=4, - message='HierarchyControllerConfig', - ) - version = proto.Field( - proto.STRING, - number=10, + proto.MESSAGE, number=4, message="HierarchyControllerConfig", ) + version = proto.Field(proto.STRING, number=10,) class ConfigSync(proto.Message): @@ -178,15 +140,8 @@ class ConfigSync(proto.Message): in “hierarchical” or “unstructured” mode. """ - git = proto.Field( - proto.MESSAGE, - number=7, - message='GitConfig', - ) - source_format = proto.Field( - proto.STRING, - number=8, - ) + git = proto.Field(proto.MESSAGE, number=7, message="GitConfig",) + source_format = proto.Field(proto.STRING, number=8,) class GitConfig(proto.Message): @@ -219,38 +174,14 @@ class GitConfig(proto.Message): is gcpServiceAccount. """ - sync_repo = proto.Field( - proto.STRING, - number=1, - ) - sync_branch = proto.Field( - proto.STRING, - number=2, - ) - policy_dir = proto.Field( - proto.STRING, - number=3, - ) - sync_wait_secs = proto.Field( - proto.INT64, - number=4, - ) - sync_rev = proto.Field( - proto.STRING, - number=5, - ) - secret_type = proto.Field( - proto.STRING, - number=6, - ) - https_proxy = proto.Field( - proto.STRING, - number=7, - ) - gcp_service_account_email = proto.Field( - proto.STRING, - number=8, - ) + sync_repo = proto.Field(proto.STRING, number=1,) + sync_branch = proto.Field(proto.STRING, number=2,) + policy_dir = proto.Field(proto.STRING, number=3,) + sync_wait_secs = proto.Field(proto.INT64, number=4,) + sync_rev = proto.Field(proto.STRING, number=5,) + secret_type = proto.Field(proto.STRING, number=6,) + https_proxy = proto.Field(proto.STRING, number=7,) + gcp_service_account_email = proto.Field(proto.STRING, number=8,) class PolicyController(proto.Message): @@ -282,36 +213,13 @@ class PolicyController(proto.Message): PolicyController. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - template_library_installed = proto.Field( - proto.BOOL, - number=2, - optional=True, - ) - audit_interval_seconds = proto.Field( - proto.INT64, - number=3, - optional=True, - ) - exemptable_namespaces = proto.RepeatedField( - proto.STRING, - number=4, - ) - referential_rules_enabled = proto.Field( - proto.BOOL, - number=5, - ) - log_denies_enabled = proto.Field( - proto.BOOL, - number=6, - ) - mutation_enabled = proto.Field( - proto.BOOL, - number=7, - ) + enabled = proto.Field(proto.BOOL, number=1,) + template_library_installed = proto.Field(proto.BOOL, number=2, optional=True,) + audit_interval_seconds = proto.Field(proto.INT64, number=3, optional=True,) + exemptable_namespaces = proto.RepeatedField(proto.STRING, number=4,) + referential_rules_enabled = proto.Field(proto.BOOL, number=5,) + log_denies_enabled = proto.Field(proto.BOOL, number=6,) + mutation_enabled = proto.Field(proto.BOOL, number=7,) class BinauthzConfig(proto.Message): @@ -321,10 +229,7 @@ class BinauthzConfig(proto.Message): Whether binauthz is enabled in this cluster. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) + enabled = proto.Field(proto.BOOL, number=1,) class HierarchyControllerConfig(proto.Message): @@ -341,18 +246,9 @@ class HierarchyControllerConfig(proto.Message): enabled in this cluster. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - enable_pod_tree_labels = proto.Field( - proto.BOOL, - number=2, - ) - enable_hierarchical_resource_quota = proto.Field( - proto.BOOL, - number=3, - ) + enabled = proto.Field(proto.BOOL, number=1,) + enable_pod_tree_labels = proto.Field(proto.BOOL, number=2,) + enable_hierarchical_resource_quota = proto.Field(proto.BOOL, number=3,) class HierarchyControllerDeploymentState(proto.Message): @@ -366,16 +262,8 @@ class HierarchyControllerDeploymentState(proto.Message): extension (e.g. v0.7.0-hc.1) """ - hnc = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - extension = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) + hnc = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + extension = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) class HierarchyControllerVersion(proto.Message): @@ -387,14 +275,8 @@ class HierarchyControllerVersion(proto.Message): Version for Hierarchy Controller extension """ - hnc = proto.Field( - proto.STRING, - number=1, - ) - extension = proto.Field( - proto.STRING, - number=2, - ) + hnc = proto.Field(proto.STRING, number=1,) + extension = proto.Field(proto.STRING, number=2,) class HierarchyControllerState(proto.Message): @@ -407,14 +289,10 @@ class HierarchyControllerState(proto.Message): """ version = proto.Field( - proto.MESSAGE, - number=1, - message='HierarchyControllerVersion', + proto.MESSAGE, number=1, message="HierarchyControllerVersion", ) state = proto.Field( - proto.MESSAGE, - number=2, - message='HierarchyControllerDeploymentState', + proto.MESSAGE, number=2, message="HierarchyControllerDeploymentState", ) @@ -429,20 +307,9 @@ class OperatorState(proto.Message): Install errors. """ - version = proto.Field( - proto.STRING, - number=1, - ) - deployment_state = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='InstallError', - ) + version = proto.Field(proto.STRING, number=1,) + deployment_state = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + errors = proto.RepeatedField(proto.MESSAGE, number=3, message="InstallError",) class InstallError(proto.Message): @@ -453,10 +320,7 @@ class InstallError(proto.Message): message """ - error_message = proto.Field( - proto.STRING, - number=1, - ) + error_message = proto.Field(proto.STRING, number=1,) class ConfigSyncState(proto.Message): @@ -473,21 +337,11 @@ class ConfigSyncState(proto.Message): configs to a cluster """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSyncVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="ConfigSyncVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='ConfigSyncDeploymentState', - ) - sync_state = proto.Field( - proto.MESSAGE, - number=3, - message='SyncState', + proto.MESSAGE, number=2, message="ConfigSyncDeploymentState", ) + sync_state = proto.Field(proto.MESSAGE, number=3, message="SyncState",) class ConfigSyncVersion(proto.Message): @@ -511,30 +365,12 @@ class ConfigSyncVersion(proto.Message): in root-reconciler pod """ - importer = proto.Field( - proto.STRING, - number=1, - ) - syncer = proto.Field( - proto.STRING, - number=2, - ) - git_sync = proto.Field( - proto.STRING, - number=3, - ) - monitor = proto.Field( - proto.STRING, - number=4, - ) - reconciler_manager = proto.Field( - proto.STRING, - number=5, - ) - root_reconciler = proto.Field( - proto.STRING, - number=6, - ) + importer = proto.Field(proto.STRING, number=1,) + syncer = proto.Field(proto.STRING, number=2,) + git_sync = proto.Field(proto.STRING, number=3,) + monitor = proto.Field(proto.STRING, number=4,) + reconciler_manager = proto.Field(proto.STRING, number=5,) + root_reconciler = proto.Field(proto.STRING, number=6,) class ConfigSyncDeploymentState(proto.Message): @@ -554,36 +390,12 @@ class ConfigSyncDeploymentState(proto.Message): Deployment state of root-reconciler """ - importer = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - syncer = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - git_sync = proto.Field( - proto.ENUM, - number=3, - enum='DeploymentState', - ) - monitor = proto.Field( - proto.ENUM, - number=4, - enum='DeploymentState', - ) - reconciler_manager = proto.Field( - proto.ENUM, - number=5, - enum='DeploymentState', - ) - root_reconciler = proto.Field( - proto.ENUM, - number=6, - enum='DeploymentState', - ) + importer = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + syncer = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + git_sync = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) + monitor = proto.Field(proto.ENUM, number=4, enum="DeploymentState",) + reconciler_manager = proto.Field(proto.ENUM, number=5, enum="DeploymentState",) + root_reconciler = proto.Field(proto.ENUM, number=6, enum="DeploymentState",) class SyncState(proto.Message): @@ -612,6 +424,7 @@ class SyncState(proto.Message): errors, although it is unlikely for that many errors to simultaneously exist. """ + class SyncCode(proto.Enum): r"""An enum representing an ACM's status syncing configs to a cluster @@ -625,37 +438,15 @@ class SyncCode(proto.Enum): UNAUTHORIZED = 6 UNREACHABLE = 7 - source_token = proto.Field( - proto.STRING, - number=1, - ) - import_token = proto.Field( - proto.STRING, - number=2, - ) - sync_token = proto.Field( - proto.STRING, - number=3, - ) - last_sync = proto.Field( - proto.STRING, - number=4, - ) + source_token = proto.Field(proto.STRING, number=1,) + import_token = proto.Field(proto.STRING, number=2,) + sync_token = proto.Field(proto.STRING, number=3,) + last_sync = proto.Field(proto.STRING, number=4,) last_sync_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - code = proto.Field( - proto.ENUM, - number=5, - enum=SyncCode, - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=6, - message='SyncError', + proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) + code = proto.Field(proto.ENUM, number=5, enum=SyncCode,) + errors = proto.RepeatedField(proto.MESSAGE, number=6, message="SyncError",) class SyncError(proto.Message): @@ -672,18 +463,10 @@ class SyncError(proto.Message): error, if any """ - code = proto.Field( - proto.STRING, - number=1, - ) - error_message = proto.Field( - proto.STRING, - number=2, - ) + code = proto.Field(proto.STRING, number=1,) + error_message = proto.Field(proto.STRING, number=2,) error_resources = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ErrorResource', + proto.MESSAGE, number=3, message="ErrorResource", ) @@ -705,23 +488,10 @@ class ErrorResource(proto.Message): causing an error """ - source_path = proto.Field( - proto.STRING, - number=1, - ) - resource_name = proto.Field( - proto.STRING, - number=2, - ) - resource_namespace = proto.Field( - proto.STRING, - number=3, - ) - resource_gvk = proto.Field( - proto.MESSAGE, - number=4, - message='GroupVersionKind', - ) + source_path = proto.Field(proto.STRING, number=1,) + resource_name = proto.Field(proto.STRING, number=2,) + resource_namespace = proto.Field(proto.STRING, number=3,) + resource_gvk = proto.Field(proto.MESSAGE, number=4, message="GroupVersionKind",) class GroupVersionKind(proto.Message): @@ -735,18 +505,9 @@ class GroupVersionKind(proto.Message): Kubernetes Kind """ - group = proto.Field( - proto.STRING, - number=1, - ) - version = proto.Field( - proto.STRING, - number=2, - ) - kind = proto.Field( - proto.STRING, - number=3, - ) + group = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) + kind = proto.Field(proto.STRING, number=3,) class PolicyControllerState(proto.Message): @@ -760,15 +521,9 @@ class PolicyControllerState(proto.Message): installation. """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='PolicyControllerVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="PolicyControllerVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='GatekeeperDeploymentState', + proto.MESSAGE, number=2, message="GatekeeperDeploymentState", ) @@ -780,10 +535,7 @@ class PolicyControllerVersion(proto.Message): ACM version, git tag, build number. """ - version = proto.Field( - proto.STRING, - number=1, - ) + version = proto.Field(proto.STRING, number=1,) class BinauthzState(proto.Message): @@ -795,16 +547,8 @@ class BinauthzState(proto.Message): The version of binauthz that is installed. """ - webhook = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - version = proto.Field( - proto.MESSAGE, - number=2, - message='BinauthzVersion', - ) + webhook = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + version = proto.Field(proto.MESSAGE, number=2, message="BinauthzVersion",) class BinauthzVersion(proto.Message): @@ -814,10 +558,7 @@ class BinauthzVersion(proto.Message): The version of the binauthz webhook. """ - webhook_version = proto.Field( - proto.STRING, - number=1, - ) + webhook_version = proto.Field(proto.STRING, number=1,) class GatekeeperDeploymentState(proto.Message): @@ -833,20 +574,10 @@ class GatekeeperDeploymentState(proto.Message): """ gatekeeper_controller_manager_state = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - gatekeeper_audit = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - gatekeeper_mutation = proto.Field( - proto.ENUM, - number=3, - enum='DeploymentState', + proto.ENUM, number=1, enum="DeploymentState", ) + gatekeeper_audit = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + gatekeeper_mutation = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/__init__.py similarity index 75% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py rename to google/cloud/gkehub/configmanagement_v1beta/__init__.py index 03dba4e..07c8615 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1beta/__init__.py @@ -42,29 +42,29 @@ from .types.configmanagement import DeploymentState __all__ = ( -'BinauthzConfig', -'BinauthzState', -'BinauthzVersion', -'ConfigSync', -'ConfigSyncDeploymentState', -'ConfigSyncState', -'ConfigSyncVersion', -'DeploymentState', -'ErrorResource', -'GatekeeperDeploymentState', -'GitConfig', -'GroupVersionKind', -'HierarchyControllerConfig', -'HierarchyControllerDeploymentState', -'HierarchyControllerState', -'HierarchyControllerVersion', -'InstallError', -'MembershipSpec', -'MembershipState', -'OperatorState', -'PolicyController', -'PolicyControllerState', -'PolicyControllerVersion', -'SyncError', -'SyncState', + "BinauthzConfig", + "BinauthzState", + "BinauthzVersion", + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "DeploymentState", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json b/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json rename to google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed b/google/cloud/gkehub/configmanagement_v1beta/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/py.typed rename to google/cloud/gkehub/configmanagement_v1beta/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py rename to google/cloud/gkehub/configmanagement_v1beta/services/__init__.py diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py similarity index 66% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py rename to google/cloud/gkehub/configmanagement_v1beta/types/__init__.py index 91fc337..b65646c 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py +++ b/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py @@ -42,29 +42,29 @@ ) __all__ = ( - 'BinauthzConfig', - 'BinauthzState', - 'BinauthzVersion', - 'ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', + "BinauthzConfig", + "BinauthzState", + "BinauthzVersion", + "ConfigSync", + "ConfigSyncDeploymentState", + "ConfigSyncState", + "ConfigSyncVersion", + "ErrorResource", + "GatekeeperDeploymentState", + "GitConfig", + "GroupVersionKind", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerState", + "HierarchyControllerVersion", + "InstallError", + "MembershipSpec", + "MembershipState", + "OperatorState", + "PolicyController", + "PolicyControllerState", + "PolicyControllerVersion", + "SyncError", + "SyncState", + "DeploymentState", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py similarity index 66% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py rename to google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py index 9ae11c3..1ecbce0 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py +++ b/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py @@ -19,33 +19,33 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.configmanagement.v1beta', + package="google.cloud.gkehub.configmanagement.v1beta", manifest={ - 'DeploymentState', - 'MembershipState', - 'MembershipSpec', - 'ConfigSync', - 'GitConfig', - 'PolicyController', - 'BinauthzConfig', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerVersion', - 'HierarchyControllerState', - 'OperatorState', - 'InstallError', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ConfigSyncDeploymentState', - 'SyncState', - 'SyncError', - 'ErrorResource', - 'GroupVersionKind', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'BinauthzState', - 'BinauthzVersion', - 'GatekeeperDeploymentState', + "DeploymentState", + "MembershipState", + "MembershipSpec", + "ConfigSync", + "GitConfig", + "PolicyController", + "BinauthzConfig", + "HierarchyControllerConfig", + "HierarchyControllerDeploymentState", + "HierarchyControllerVersion", + "HierarchyControllerState", + "OperatorState", + "InstallError", + "ConfigSyncState", + "ConfigSyncVersion", + "ConfigSyncDeploymentState", + "SyncState", + "SyncError", + "ErrorResource", + "GroupVersionKind", + "PolicyControllerState", + "PolicyControllerVersion", + "BinauthzState", + "BinauthzVersion", + "GatekeeperDeploymentState", }, ) @@ -87,39 +87,16 @@ class MembershipState(proto.Message): Hierarchy Controller status """ - cluster_name = proto.Field( - proto.STRING, - number=1, - ) - membership_spec = proto.Field( - proto.MESSAGE, - number=2, - message='MembershipSpec', - ) - operator_state = proto.Field( - proto.MESSAGE, - number=3, - message='OperatorState', - ) - config_sync_state = proto.Field( - proto.MESSAGE, - number=4, - message='ConfigSyncState', - ) + cluster_name = proto.Field(proto.STRING, number=1,) + membership_spec = proto.Field(proto.MESSAGE, number=2, message="MembershipSpec",) + operator_state = proto.Field(proto.MESSAGE, number=3, message="OperatorState",) + config_sync_state = proto.Field(proto.MESSAGE, number=4, message="ConfigSyncState",) policy_controller_state = proto.Field( - proto.MESSAGE, - number=5, - message='PolicyControllerState', - ) - binauthz_state = proto.Field( - proto.MESSAGE, - number=6, - message='BinauthzState', + proto.MESSAGE, number=5, message="PolicyControllerState", ) + binauthz_state = proto.Field(proto.MESSAGE, number=6, message="BinauthzState",) hierarchy_controller_state = proto.Field( - proto.MESSAGE, - number=7, - message='HierarchyControllerState', + proto.MESSAGE, number=7, message="HierarchyControllerState", ) @@ -142,30 +119,15 @@ class MembershipSpec(proto.Message): Version of ACM installed. """ - config_sync = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSync', - ) + config_sync = proto.Field(proto.MESSAGE, number=1, message="ConfigSync",) policy_controller = proto.Field( - proto.MESSAGE, - number=2, - message='PolicyController', - ) - binauthz = proto.Field( - proto.MESSAGE, - number=3, - message='BinauthzConfig', + proto.MESSAGE, number=2, message="PolicyController", ) + binauthz = proto.Field(proto.MESSAGE, number=3, message="BinauthzConfig",) hierarchy_controller = proto.Field( - proto.MESSAGE, - number=4, - message='HierarchyControllerConfig', - ) - version = proto.Field( - proto.STRING, - number=10, + proto.MESSAGE, number=4, message="HierarchyControllerConfig", ) + version = proto.Field(proto.STRING, number=10,) class ConfigSync(proto.Message): @@ -178,15 +140,8 @@ class ConfigSync(proto.Message): in “hierarchical” or “unstructured” mode. """ - git = proto.Field( - proto.MESSAGE, - number=7, - message='GitConfig', - ) - source_format = proto.Field( - proto.STRING, - number=8, - ) + git = proto.Field(proto.MESSAGE, number=7, message="GitConfig",) + source_format = proto.Field(proto.STRING, number=8,) class GitConfig(proto.Message): @@ -219,38 +174,14 @@ class GitConfig(proto.Message): is gcpServiceAccount. """ - sync_repo = proto.Field( - proto.STRING, - number=1, - ) - sync_branch = proto.Field( - proto.STRING, - number=2, - ) - policy_dir = proto.Field( - proto.STRING, - number=3, - ) - sync_wait_secs = proto.Field( - proto.INT64, - number=4, - ) - sync_rev = proto.Field( - proto.STRING, - number=5, - ) - secret_type = proto.Field( - proto.STRING, - number=6, - ) - https_proxy = proto.Field( - proto.STRING, - number=7, - ) - gcp_service_account_email = proto.Field( - proto.STRING, - number=8, - ) + sync_repo = proto.Field(proto.STRING, number=1,) + sync_branch = proto.Field(proto.STRING, number=2,) + policy_dir = proto.Field(proto.STRING, number=3,) + sync_wait_secs = proto.Field(proto.INT64, number=4,) + sync_rev = proto.Field(proto.STRING, number=5,) + secret_type = proto.Field(proto.STRING, number=6,) + https_proxy = proto.Field(proto.STRING, number=7,) + gcp_service_account_email = proto.Field(proto.STRING, number=8,) class PolicyController(proto.Message): @@ -279,32 +210,12 @@ class PolicyController(proto.Message): Logs all denies and dry run failures. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - template_library_installed = proto.Field( - proto.BOOL, - number=2, - optional=True, - ) - audit_interval_seconds = proto.Field( - proto.INT64, - number=3, - optional=True, - ) - exemptable_namespaces = proto.RepeatedField( - proto.STRING, - number=4, - ) - referential_rules_enabled = proto.Field( - proto.BOOL, - number=5, - ) - log_denies_enabled = proto.Field( - proto.BOOL, - number=6, - ) + enabled = proto.Field(proto.BOOL, number=1,) + template_library_installed = proto.Field(proto.BOOL, number=2, optional=True,) + audit_interval_seconds = proto.Field(proto.INT64, number=3, optional=True,) + exemptable_namespaces = proto.RepeatedField(proto.STRING, number=4,) + referential_rules_enabled = proto.Field(proto.BOOL, number=5,) + log_denies_enabled = proto.Field(proto.BOOL, number=6,) class BinauthzConfig(proto.Message): @@ -314,10 +225,7 @@ class BinauthzConfig(proto.Message): Whether binauthz is enabled in this cluster. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) + enabled = proto.Field(proto.BOOL, number=1,) class HierarchyControllerConfig(proto.Message): @@ -334,18 +242,9 @@ class HierarchyControllerConfig(proto.Message): enabled in this cluster. """ - enabled = proto.Field( - proto.BOOL, - number=1, - ) - enable_pod_tree_labels = proto.Field( - proto.BOOL, - number=2, - ) - enable_hierarchical_resource_quota = proto.Field( - proto.BOOL, - number=3, - ) + enabled = proto.Field(proto.BOOL, number=1,) + enable_pod_tree_labels = proto.Field(proto.BOOL, number=2,) + enable_hierarchical_resource_quota = proto.Field(proto.BOOL, number=3,) class HierarchyControllerDeploymentState(proto.Message): @@ -359,16 +258,8 @@ class HierarchyControllerDeploymentState(proto.Message): extension (e.g. v0.7.0-hc.1) """ - hnc = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - extension = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) + hnc = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + extension = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) class HierarchyControllerVersion(proto.Message): @@ -380,14 +271,8 @@ class HierarchyControllerVersion(proto.Message): Version for Hierarchy Controller extension """ - hnc = proto.Field( - proto.STRING, - number=1, - ) - extension = proto.Field( - proto.STRING, - number=2, - ) + hnc = proto.Field(proto.STRING, number=1,) + extension = proto.Field(proto.STRING, number=2,) class HierarchyControllerState(proto.Message): @@ -400,14 +285,10 @@ class HierarchyControllerState(proto.Message): """ version = proto.Field( - proto.MESSAGE, - number=1, - message='HierarchyControllerVersion', + proto.MESSAGE, number=1, message="HierarchyControllerVersion", ) state = proto.Field( - proto.MESSAGE, - number=2, - message='HierarchyControllerDeploymentState', + proto.MESSAGE, number=2, message="HierarchyControllerDeploymentState", ) @@ -422,20 +303,9 @@ class OperatorState(proto.Message): Install errors. """ - version = proto.Field( - proto.STRING, - number=1, - ) - deployment_state = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='InstallError', - ) + version = proto.Field(proto.STRING, number=1,) + deployment_state = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + errors = proto.RepeatedField(proto.MESSAGE, number=3, message="InstallError",) class InstallError(proto.Message): @@ -446,10 +316,7 @@ class InstallError(proto.Message): message """ - error_message = proto.Field( - proto.STRING, - number=1, - ) + error_message = proto.Field(proto.STRING, number=1,) class ConfigSyncState(proto.Message): @@ -466,21 +333,11 @@ class ConfigSyncState(proto.Message): configs to a cluster """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='ConfigSyncVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="ConfigSyncVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='ConfigSyncDeploymentState', - ) - sync_state = proto.Field( - proto.MESSAGE, - number=3, - message='SyncState', + proto.MESSAGE, number=2, message="ConfigSyncDeploymentState", ) + sync_state = proto.Field(proto.MESSAGE, number=3, message="SyncState",) class ConfigSyncVersion(proto.Message): @@ -504,30 +361,12 @@ class ConfigSyncVersion(proto.Message): in root-reconciler pod """ - importer = proto.Field( - proto.STRING, - number=1, - ) - syncer = proto.Field( - proto.STRING, - number=2, - ) - git_sync = proto.Field( - proto.STRING, - number=3, - ) - monitor = proto.Field( - proto.STRING, - number=4, - ) - reconciler_manager = proto.Field( - proto.STRING, - number=5, - ) - root_reconciler = proto.Field( - proto.STRING, - number=6, - ) + importer = proto.Field(proto.STRING, number=1,) + syncer = proto.Field(proto.STRING, number=2,) + git_sync = proto.Field(proto.STRING, number=3,) + monitor = proto.Field(proto.STRING, number=4,) + reconciler_manager = proto.Field(proto.STRING, number=5,) + root_reconciler = proto.Field(proto.STRING, number=6,) class ConfigSyncDeploymentState(proto.Message): @@ -547,36 +386,12 @@ class ConfigSyncDeploymentState(proto.Message): Deployment state of root-reconciler """ - importer = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - syncer = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', - ) - git_sync = proto.Field( - proto.ENUM, - number=3, - enum='DeploymentState', - ) - monitor = proto.Field( - proto.ENUM, - number=4, - enum='DeploymentState', - ) - reconciler_manager = proto.Field( - proto.ENUM, - number=5, - enum='DeploymentState', - ) - root_reconciler = proto.Field( - proto.ENUM, - number=6, - enum='DeploymentState', - ) + importer = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + syncer = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) + git_sync = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) + monitor = proto.Field(proto.ENUM, number=4, enum="DeploymentState",) + reconciler_manager = proto.Field(proto.ENUM, number=5, enum="DeploymentState",) + root_reconciler = proto.Field(proto.ENUM, number=6, enum="DeploymentState",) class SyncState(proto.Message): @@ -605,6 +420,7 @@ class SyncState(proto.Message): errors, although it is unlikely for that many errors to simultaneously exist. """ + class SyncCode(proto.Enum): r"""An enum representing an ACM's status syncing configs to a cluster @@ -618,37 +434,15 @@ class SyncCode(proto.Enum): UNAUTHORIZED = 6 UNREACHABLE = 7 - source_token = proto.Field( - proto.STRING, - number=1, - ) - import_token = proto.Field( - proto.STRING, - number=2, - ) - sync_token = proto.Field( - proto.STRING, - number=3, - ) - last_sync = proto.Field( - proto.STRING, - number=4, - ) + source_token = proto.Field(proto.STRING, number=1,) + import_token = proto.Field(proto.STRING, number=2,) + sync_token = proto.Field(proto.STRING, number=3,) + last_sync = proto.Field(proto.STRING, number=4,) last_sync_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - code = proto.Field( - proto.ENUM, - number=5, - enum=SyncCode, - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=6, - message='SyncError', + proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) + code = proto.Field(proto.ENUM, number=5, enum=SyncCode,) + errors = proto.RepeatedField(proto.MESSAGE, number=6, message="SyncError",) class SyncError(proto.Message): @@ -665,18 +459,10 @@ class SyncError(proto.Message): error, if any """ - code = proto.Field( - proto.STRING, - number=1, - ) - error_message = proto.Field( - proto.STRING, - number=2, - ) + code = proto.Field(proto.STRING, number=1,) + error_message = proto.Field(proto.STRING, number=2,) error_resources = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ErrorResource', + proto.MESSAGE, number=3, message="ErrorResource", ) @@ -698,23 +484,10 @@ class ErrorResource(proto.Message): causing an error """ - source_path = proto.Field( - proto.STRING, - number=1, - ) - resource_name = proto.Field( - proto.STRING, - number=2, - ) - resource_namespace = proto.Field( - proto.STRING, - number=3, - ) - resource_gvk = proto.Field( - proto.MESSAGE, - number=4, - message='GroupVersionKind', - ) + source_path = proto.Field(proto.STRING, number=1,) + resource_name = proto.Field(proto.STRING, number=2,) + resource_namespace = proto.Field(proto.STRING, number=3,) + resource_gvk = proto.Field(proto.MESSAGE, number=4, message="GroupVersionKind",) class GroupVersionKind(proto.Message): @@ -728,18 +501,9 @@ class GroupVersionKind(proto.Message): Kubernetes Kind """ - group = proto.Field( - proto.STRING, - number=1, - ) - version = proto.Field( - proto.STRING, - number=2, - ) - kind = proto.Field( - proto.STRING, - number=3, - ) + group = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) + kind = proto.Field(proto.STRING, number=3,) class PolicyControllerState(proto.Message): @@ -753,15 +517,9 @@ class PolicyControllerState(proto.Message): installation. """ - version = proto.Field( - proto.MESSAGE, - number=1, - message='PolicyControllerVersion', - ) + version = proto.Field(proto.MESSAGE, number=1, message="PolicyControllerVersion",) deployment_state = proto.Field( - proto.MESSAGE, - number=2, - message='GatekeeperDeploymentState', + proto.MESSAGE, number=2, message="GatekeeperDeploymentState", ) @@ -773,10 +531,7 @@ class PolicyControllerVersion(proto.Message): ACM version, git tag, build number. """ - version = proto.Field( - proto.STRING, - number=1, - ) + version = proto.Field(proto.STRING, number=1,) class BinauthzState(proto.Message): @@ -788,16 +543,8 @@ class BinauthzState(proto.Message): The version of binauthz that is installed. """ - webhook = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - version = proto.Field( - proto.MESSAGE, - number=2, - message='BinauthzVersion', - ) + webhook = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) + version = proto.Field(proto.MESSAGE, number=2, message="BinauthzVersion",) class BinauthzVersion(proto.Message): @@ -807,10 +554,7 @@ class BinauthzVersion(proto.Message): The version of the binauthz webhook. """ - webhook_version = proto.Field( - proto.STRING, - number=1, - ) + webhook_version = proto.Field(proto.STRING, number=1,) class GatekeeperDeploymentState(proto.Message): @@ -823,15 +567,9 @@ class GatekeeperDeploymentState(proto.Message): """ gatekeeper_controller_manager_state = proto.Field( - proto.ENUM, - number=1, - enum='DeploymentState', - ) - gatekeeper_audit = proto.Field( - proto.ENUM, - number=2, - enum='DeploymentState', + proto.ENUM, number=1, enum="DeploymentState", ) + gatekeeper_audit = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py b/google/cloud/gkehub/metering/__init__.py similarity index 95% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py rename to google/cloud/gkehub/metering/__init__.py index faffa99..f84a687 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/metering/__init__.py +++ b/google/cloud/gkehub/metering/__init__.py @@ -17,5 +17,4 @@ from google.cloud.gkehub.metering_v1beta.types.metering import MembershipState -__all__ = ('MembershipState', -) +__all__ = ("MembershipState",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed b/google/cloud/gkehub/metering/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering/py.typed rename to google/cloud/gkehub/metering/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py b/google/cloud/gkehub/metering_v1alpha/__init__.py similarity index 95% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py rename to google/cloud/gkehub/metering_v1alpha/__init__.py index fe15d24..04fad4f 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/__init__.py +++ b/google/cloud/gkehub/metering_v1alpha/__init__.py @@ -17,6 +17,4 @@ from .types.metering import MembershipState -__all__ = ( -'MembershipState', -) +__all__ = ("MembershipState",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json b/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json rename to google/cloud/gkehub/metering_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed b/google/cloud/gkehub/metering_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/py.typed rename to google/cloud/gkehub/metering_v1alpha/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py b/google/cloud/gkehub/metering_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py rename to google/cloud/gkehub/metering_v1alpha/services/__init__.py diff --git a/google/cloud/gkehub/metering_v1alpha/types/__init__.py b/google/cloud/gkehub/metering_v1alpha/types/__init__.py new file mode 100644 index 0000000..7cf2c8d --- /dev/null +++ b/google/cloud/gkehub/metering_v1alpha/types/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .metering import MembershipState + +__all__ = ("MembershipState",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py b/google/cloud/gkehub/metering_v1alpha/types/metering.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py rename to google/cloud/gkehub/metering_v1alpha/types/metering.py index d7cf3d5..f4de81e 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/metering.py +++ b/google/cloud/gkehub/metering_v1alpha/types/metering.py @@ -19,10 +19,7 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.metering.v1beta', - manifest={ - 'MembershipState', - }, + package="google.cloud.gkehub.metering.v1alpha", manifest={"MembershipState",}, ) @@ -39,14 +36,9 @@ class MembershipState(proto.Message): """ last_measurement_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - precise_last_measured_cluster_vcpu_capacity = proto.Field( - proto.FLOAT, - number=3, + proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) + precise_last_measured_cluster_vcpu_capacity = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py b/google/cloud/gkehub/metering_v1beta/__init__.py similarity index 95% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py rename to google/cloud/gkehub/metering_v1beta/__init__.py index fe15d24..04fad4f 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/__init__.py +++ b/google/cloud/gkehub/metering_v1beta/__init__.py @@ -17,6 +17,4 @@ from .types.metering import MembershipState -__all__ = ( -'MembershipState', -) +__all__ = ("MembershipState",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json b/google/cloud/gkehub/metering_v1beta/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/gapic_metadata.json rename to google/cloud/gkehub/metering_v1beta/gapic_metadata.json diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed b/google/cloud/gkehub/metering_v1beta/py.typed similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering/py.typed rename to google/cloud/gkehub/metering_v1beta/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py b/google/cloud/gkehub/metering_v1beta/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/services/__init__.py rename to google/cloud/gkehub/metering_v1beta/services/__init__.py diff --git a/google/cloud/gkehub/metering_v1beta/types/__init__.py b/google/cloud/gkehub/metering_v1beta/types/__init__.py new file mode 100644 index 0000000..7cf2c8d --- /dev/null +++ b/google/cloud/gkehub/metering_v1beta/types/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .metering import MembershipState + +__all__ = ("MembershipState",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py b/google/cloud/gkehub/metering_v1beta/types/metering.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py rename to google/cloud/gkehub/metering_v1beta/types/metering.py index ad80813..538e076 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/metering.py +++ b/google/cloud/gkehub/metering_v1beta/types/metering.py @@ -19,10 +19,7 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.metering.v1alpha', - manifest={ - 'MembershipState', - }, + package="google.cloud.gkehub.metering.v1beta", manifest={"MembershipState",}, ) @@ -39,14 +36,9 @@ class MembershipState(proto.Message): """ last_measurement_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - precise_last_measured_cluster_vcpu_capacity = proto.Field( - proto.FLOAT, - number=3, + proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) + precise_last_measured_cluster_vcpu_capacity = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py b/google/cloud/gkehub/multiclusteringress/__init__.py similarity index 85% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py rename to google/cloud/gkehub/multiclusteringress/__init__.py index 83bd925..d9ed69d 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/__init__.py +++ b/google/cloud/gkehub/multiclusteringress/__init__.py @@ -15,9 +15,14 @@ # -from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import FeatureSpec -from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import Billing +from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import ( + FeatureSpec, +) +from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import ( + Billing, +) -__all__ = ('FeatureSpec', - 'Billing', +__all__ = ( + "FeatureSpec", + "Billing", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed b/google/cloud/gkehub/multiclusteringress/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/py.typed rename to google/cloud/gkehub/multiclusteringress/py.typed diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py b/google/cloud/gkehub/multiclusteringress_v1/__init__.py similarity index 95% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1/__init__.py index e418f95..3870c5b 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/__init__.py +++ b/google/cloud/gkehub/multiclusteringress_v1/__init__.py @@ -17,6 +17,4 @@ from .types.multiclusteringress import FeatureSpec -__all__ = ( -'FeatureSpec', -) +__all__ = ("FeatureSpec",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json b/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json rename to google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed b/google/cloud/gkehub/multiclusteringress_v1/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/py.typed rename to google/cloud/gkehub/multiclusteringress_v1/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py b/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1/services/__init__.py diff --git a/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py b/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py new file mode 100644 index 0000000..be71b4a --- /dev/null +++ b/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 .multiclusteringress import FeatureSpec + +__all__ = ("FeatureSpec",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py similarity index 85% rename from owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py rename to google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py index c6d0fff..740be66 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py +++ b/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py @@ -17,10 +17,7 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.multiclusteringress.v1', - manifest={ - 'FeatureSpec', - }, + package="google.cloud.gkehub.multiclusteringress.v1", manifest={"FeatureSpec",}, ) @@ -35,10 +32,7 @@ class FeatureSpec(proto.Message): ``projects/foo-proj/locations/global/memberships/bar`` """ - config_membership = proto.Field( - proto.STRING, - number=1, - ) + config_membership = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py similarity index 95% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py index a8fd7c2..661754d 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py +++ b/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py @@ -19,6 +19,6 @@ from .types.multiclusteringress import Billing __all__ = ( -'Billing', -'FeatureSpec', + "Billing", + "FeatureSpec", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json b/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json rename to google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed b/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/py.typed rename to google/cloud/gkehub/multiclusteringress_v1alpha/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py similarity index 95% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py index 28b5fac..29ec9f8 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py +++ b/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py @@ -19,6 +19,6 @@ ) __all__ = ( - 'FeatureSpec', - 'Billing', + "FeatureSpec", + "Billing", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py rename to google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py index 5a73c5e..0cee16e 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py +++ b/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py @@ -17,11 +17,8 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.multiclusteringress.v1alpha', - manifest={ - 'Billing', - 'FeatureSpec', - }, + package="google.cloud.gkehub.multiclusteringress.v1alpha", + manifest={"Billing", "FeatureSpec",}, ) @@ -47,15 +44,8 @@ class FeatureSpec(proto.Message): Customer's billing structure """ - config_membership = proto.Field( - proto.STRING, - number=1, - ) - billing = proto.Field( - proto.ENUM, - number=2, - enum='Billing', - ) + config_membership = proto.Field(proto.STRING, number=1,) + billing = proto.Field(proto.ENUM, number=2, enum="Billing",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py similarity index 95% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1beta/__init__.py index a8fd7c2..661754d 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py +++ b/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py @@ -19,6 +19,6 @@ from .types.multiclusteringress import Billing __all__ = ( -'Billing', -'FeatureSpec', + "Billing", + "FeatureSpec", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json b/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json rename to google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed b/google/cloud/gkehub/multiclusteringress_v1beta/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed rename to google/cloud/gkehub/multiclusteringress_v1beta/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py similarity index 95% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py rename to google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py index 28b5fac..29ec9f8 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py +++ b/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py @@ -19,6 +19,6 @@ ) __all__ = ( - 'FeatureSpec', - 'Billing', + "FeatureSpec", + "Billing", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py rename to google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py index 344df3c..ae90a77 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py +++ b/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py @@ -17,11 +17,8 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.multiclusteringress.v1beta', - manifest={ - 'Billing', - 'FeatureSpec', - }, + package="google.cloud.gkehub.multiclusteringress.v1beta", + manifest={"Billing", "FeatureSpec",}, ) @@ -47,15 +44,8 @@ class FeatureSpec(proto.Message): Customer's billing structure """ - config_membership = proto.Field( - proto.STRING, - number=1, - ) - billing = proto.Field( - proto.ENUM, - number=2, - enum='Billing', - ) + config_membership = proto.Field(proto.STRING, number=1,) + billing = proto.Field(proto.ENUM, number=2, enum="Billing",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py b/google/cloud/gkehub/servicemesh/__init__.py similarity index 86% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py rename to google/cloud/gkehub/servicemesh/__init__.py index e3c0a79..cf91ada 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/__init__.py +++ b/google/cloud/gkehub/servicemesh/__init__.py @@ -16,12 +16,15 @@ from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import AnalysisMessage -from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import AnalysisMessageBase +from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import ( + AnalysisMessageBase, +) from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import FeatureState from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import MembershipState -__all__ = ('AnalysisMessage', - 'AnalysisMessageBase', - 'FeatureState', - 'MembershipState', +__all__ = ( + "AnalysisMessage", + "AnalysisMessageBase", + "FeatureState", + "MembershipState", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed b/google/cloud/gkehub/servicemesh/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh/py.typed rename to google/cloud/gkehub/servicemesh/py.typed diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/__init__.py similarity index 89% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py rename to google/cloud/gkehub/servicemesh_v1alpha/__init__.py index 92dad68..92d5f3b 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/__init__.py +++ b/google/cloud/gkehub/servicemesh_v1alpha/__init__.py @@ -21,8 +21,8 @@ from .types.servicemesh import MembershipState __all__ = ( -'AnalysisMessage', -'AnalysisMessageBase', -'FeatureState', -'MembershipState', + "AnalysisMessage", + "AnalysisMessageBase", + "FeatureState", + "MembershipState", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json b/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json rename to google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed b/google/cloud/gkehub/servicemesh_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/py.typed rename to google/cloud/gkehub/servicemesh_v1alpha/py.typed diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/__init__.py rename to google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py similarity index 88% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py rename to google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py index b3b75a3..f3cc1d6 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py +++ b/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py @@ -21,8 +21,8 @@ ) __all__ = ( - 'AnalysisMessage', - 'AnalysisMessageBase', - 'FeatureState', - 'MembershipState', + "AnalysisMessage", + "AnalysisMessageBase", + "FeatureState", + "MembershipState", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py b/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py similarity index 80% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py rename to google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py index c524b4c..9609fc6 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py +++ b/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py @@ -19,12 +19,12 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.servicemesh.v1alpha', + package="google.cloud.gkehub.servicemesh.v1alpha", manifest={ - 'FeatureState', - 'MembershipState', - 'AnalysisMessageBase', - 'AnalysisMessage', + "FeatureState", + "MembershipState", + "AnalysisMessageBase", + "AnalysisMessage", }, ) @@ -40,9 +40,7 @@ class FeatureState(proto.Message): """ analysis_messages = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='AnalysisMessage', + proto.MESSAGE, number=1, message="AnalysisMessage", ) @@ -57,9 +55,7 @@ class MembershipState(proto.Message): """ analysis_messages = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='AnalysisMessage', + proto.MESSAGE, number=1, message="AnalysisMessage", ) @@ -76,6 +72,7 @@ class AnalysisMessageBase(proto.Message): A url pointing to the Service Mesh or Istio documentation for this specific error type. """ + class Level(proto.Enum): r"""The values here are chosen so that more severe messages get sorted higher, as well as leaving space in between to add more @@ -106,29 +103,12 @@ class Type(proto.Message): message type.) """ - display_name = proto.Field( - proto.STRING, - number=1, - ) - code = proto.Field( - proto.STRING, - number=2, - ) - - type_ = proto.Field( - proto.MESSAGE, - number=1, - message=Type, - ) - level = proto.Field( - proto.ENUM, - number=2, - enum=Level, - ) - documentation_url = proto.Field( - proto.STRING, - number=3, - ) + display_name = proto.Field(proto.STRING, number=1,) + code = proto.Field(proto.STRING, number=2,) + + type_ = proto.Field(proto.MESSAGE, number=1, message=Type,) + level = proto.Field(proto.ENUM, number=2, enum=Level,) + documentation_url = proto.Field(proto.STRING, number=3,) class AnalysisMessage(proto.Message): @@ -156,24 +136,10 @@ class AnalysisMessage(proto.Message): message_base.type) to produce an internationalized message. """ - message_base = proto.Field( - proto.MESSAGE, - number=1, - message='AnalysisMessageBase', - ) - description = proto.Field( - proto.STRING, - number=2, - ) - resource_paths = proto.RepeatedField( - proto.STRING, - number=3, - ) - args = proto.Field( - proto.MESSAGE, - number=4, - message=struct_pb2.Struct, - ) + message_base = proto.Field(proto.MESSAGE, number=1, message="AnalysisMessageBase",) + description = proto.Field(proto.STRING, number=2,) + resource_paths = proto.RepeatedField(proto.STRING, number=3,) + args = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Struct,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py b/google/cloud/gkehub_v1/__init__.py similarity index 71% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py rename to google/cloud/gkehub_v1/__init__.py index e699a81..e233c40 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/__init__.py +++ b/google/cloud/gkehub_v1/__init__.py @@ -49,36 +49,36 @@ from .types.service import UpdateMembershipRequest __all__ = ( - 'GkeHubAsyncClient', -'Authority', -'CommonFeatureSpec', -'CommonFeatureState', -'ConnectAgentResource', -'CreateFeatureRequest', -'CreateMembershipRequest', -'DeleteFeatureRequest', -'DeleteMembershipRequest', -'Feature', -'FeatureResourceState', -'FeatureState', -'GenerateConnectManifestRequest', -'GenerateConnectManifestResponse', -'GetFeatureRequest', -'GetMembershipRequest', -'GkeCluster', -'GkeHubClient', -'KubernetesMetadata', -'ListFeaturesRequest', -'ListFeaturesResponse', -'ListMembershipsRequest', -'ListMembershipsResponse', -'Membership', -'MembershipEndpoint', -'MembershipFeatureSpec', -'MembershipFeatureState', -'MembershipState', -'OperationMetadata', -'TypeMeta', -'UpdateFeatureRequest', -'UpdateMembershipRequest', + "GkeHubAsyncClient", + "Authority", + "CommonFeatureSpec", + "CommonFeatureState", + "ConnectAgentResource", + "CreateFeatureRequest", + "CreateMembershipRequest", + "DeleteFeatureRequest", + "DeleteMembershipRequest", + "Feature", + "FeatureResourceState", + "FeatureState", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "GetFeatureRequest", + "GetMembershipRequest", + "GkeCluster", + "GkeHubClient", + "KubernetesMetadata", + "ListFeaturesRequest", + "ListFeaturesResponse", + "ListMembershipsRequest", + "ListMembershipsResponse", + "Membership", + "MembershipEndpoint", + "MembershipFeatureSpec", + "MembershipFeatureState", + "MembershipState", + "OperationMetadata", + "TypeMeta", + "UpdateFeatureRequest", + "UpdateMembershipRequest", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json b/google/cloud/gkehub_v1/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/gapic_metadata.json rename to google/cloud/gkehub_v1/gapic_metadata.json diff --git a/owl-bot-staging/v1/google/cloud/gkehub/py.typed b/google/cloud/gkehub_v1/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub/py.typed rename to google/cloud/gkehub_v1/py.typed diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py b/google/cloud/gkehub_v1/services/__init__.py similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py rename to google/cloud/gkehub_v1/services/__init__.py diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py b/google/cloud/gkehub_v1/services/gke_hub/__init__.py similarity index 93% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py rename to google/cloud/gkehub_v1/services/gke_hub/__init__.py index 7304648..73e44b4 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/__init__.py +++ b/google/cloud/gkehub_v1/services/gke_hub/__init__.py @@ -17,6 +17,6 @@ from .async_client import GkeHubAsyncClient __all__ = ( - 'GkeHubClient', - 'GkeHubAsyncClient', + "GkeHubClient", + "GkeHubAsyncClient", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py b/google/cloud/gkehub_v1/services/gke_hub/async_client.py similarity index 80% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py rename to google/cloud/gkehub_v1/services/gke_hub/async_client.py index f986b07..632ae32 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/async_client.py +++ b/google/cloud/gkehub_v1/services/gke_hub/async_client.py @@ -19,12 +19,12 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -67,11 +67,15 @@ class GkeHubAsyncClient: membership_path = staticmethod(GkeHubClient.membership_path) parse_membership_path = staticmethod(GkeHubClient.parse_membership_path) common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + parse_common_billing_account_path = staticmethod( + GkeHubClient.parse_common_billing_account_path + ) common_folder_path = staticmethod(GkeHubClient.common_folder_path) parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + parse_common_organization_path = staticmethod( + GkeHubClient.parse_common_organization_path + ) common_project_path = staticmethod(GkeHubClient.common_project_path) parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) common_location_path = staticmethod(GkeHubClient.common_location_path) @@ -119,14 +123,18 @@ def transport(self) -> GkeHubTransport: """ return self._client.transport - get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + get_transport_class = functools.partial( + type(GkeHubClient).get_transport_class, type(GkeHubClient) + ) - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -164,17 +172,17 @@ def __init__(self, *, transport=transport, client_options=client_options, client_info=client_info, - ) - async def list_memberships(self, - request: service.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsAsyncPager: + async def list_memberships( + self, + request: service.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsAsyncPager: r"""Lists Memberships in a given project and location. Args: @@ -208,8 +216,10 @@ async def list_memberships(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.ListMembershipsRequest(request) @@ -229,39 +239,30 @@ async def list_memberships(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListMembershipsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - async def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesAsyncPager: + async def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: r"""Lists Features in a given project and location. Args: @@ -295,8 +296,10 @@ async def list_features(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.ListFeaturesRequest(request) @@ -316,39 +319,30 @@ async def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - async def get_membership(self, - request: service.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: + async def get_membership( + self, + request: service.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: r"""Gets the details of a Membership. Args: @@ -379,8 +373,10 @@ async def get_membership(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.GetMembershipRequest(request) @@ -400,30 +396,24 @@ async def get_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + async def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -454,8 +444,10 @@ async def get_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.GetFeatureRequest(request) @@ -475,32 +467,26 @@ async def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_membership(self, - request: service.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def create_membership( + self, + request: service.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Creates a new Membership. **This is currently only supported for GKE clusters on Google @@ -561,8 +547,10 @@ async def create_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, membership_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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.CreateMembershipRequest(request) @@ -586,18 +574,11 @@ async def create_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -610,16 +591,17 @@ async def create_membership(self, # Done; return the response. return response - async def create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Adds a new Feature. Args: @@ -664,8 +646,10 @@ async def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.CreateFeatureRequest(request) @@ -689,18 +673,11 @@ async def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -713,14 +690,15 @@ async def create_feature(self, # Done; return the response. return response - async def delete_membership(self, - request: service.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def delete_membership( + self, + request: service.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Removes a Membership. **This is currently only supported for GKE clusters on Google @@ -769,8 +747,10 @@ async def delete_membership(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.DeleteMembershipRequest(request) @@ -790,18 +770,11 @@ async def delete_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -814,14 +787,15 @@ async def delete_membership(self, # Done; return the response. return response - async def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Removes a Feature. Args: @@ -865,8 +839,10 @@ async def delete_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.DeleteFeatureRequest(request) @@ -886,18 +862,11 @@ async def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -910,16 +879,17 @@ async def delete_feature(self, # Done; return the response. return response - async def update_membership(self, - request: service.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def update_membership( + self, + request: service.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Updates an existing Membership. Args: @@ -972,8 +942,10 @@ async def update_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.UpdateMembershipRequest(request) @@ -997,18 +969,11 @@ async def update_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1021,16 +986,17 @@ async def update_membership(self, # Done; return the response. return response - async def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Updates an existing Feature. Args: @@ -1083,8 +1049,10 @@ async def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.UpdateFeatureRequest(request) @@ -1108,18 +1076,11 @@ async def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1132,13 +1093,14 @@ async def update_feature(self, # Done; return the response. return response - async def generate_connect_manifest(self, - request: service.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.GenerateConnectManifestResponse: + async def generate_connect_manifest( + self, + request: service.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.GenerateConnectManifestResponse: r"""Generates the manifest for deployment of the GKE connect agent. **This method is used internally by Google-provided libraries.** @@ -1176,36 +1138,22 @@ async def generate_connect_manifest(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubAsyncClient", -) +__all__ = ("GkeHubAsyncClient",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py b/google/cloud/gkehub_v1/services/gke_hub/client.py similarity index 80% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py rename to google/cloud/gkehub_v1/services/gke_hub/client.py index 85ddb7e..ecca4ad 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/client.py +++ b/google/cloud/gkehub_v1/services/gke_hub/client.py @@ -21,14 +21,14 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -51,13 +51,12 @@ class GkeHubClientMeta(type): support objects (e.g. transport) without polluting the client instance objects. """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] _transport_registry["grpc"] = GkeHubGrpcTransport _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - def get_transport_class(cls, - label: str = None, - ) -> Type[GkeHubTransport]: + def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: """Returns an appropriate transport class. Args: @@ -159,8 +158,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: GkeHubClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) + credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs) @@ -177,88 +175,104 @@ def transport(self) -> GkeHubTransport: return self._transport @staticmethod - def feature_path(project: str,location: str,feature: str,) -> str: + def feature_path(project: str, location: str, feature: str,) -> str: """Returns a fully-qualified feature string.""" - return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + return "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) @staticmethod - def parse_feature_path(path: str) -> Dict[str,str]: + def parse_feature_path(path: str) -> Dict[str, str]: """Parses a feature path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def membership_path(project: str,location: str,membership: str,) -> str: + def membership_path(project: str, location: str, membership: str,) -> str: """Returns a fully-qualified membership string.""" - return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + return "projects/{project}/locations/{location}/memberships/{membership}".format( + project=project, location=location, membership=membership, + ) @staticmethod - def parse_membership_path(path: str) -> Dict[str,str]: + def parse_membership_path(path: str) -> Dict[str, str]: """Parses a membership path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: + def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: + def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P.+?)$", path) 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]: + def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P.+?)$", path) 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]: + def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P.+?)$", path) 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]: + def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P.+?)$", path) 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, ) + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: + def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -302,7 +316,9 @@ def __init__(self, *, client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + use_client_cert = bool( + util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + ) client_cert_source_func = None is_mtls = False @@ -343,8 +359,10 @@ def __init__(self, *, if isinstance(transport, GkeHubTransport): # transport is a GkeHubTransport instance. if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) if client_options.scopes: raise ValueError( "When providing a transport instance, provide its scopes " @@ -363,14 +381,15 @@ def __init__(self, *, client_info=client_info, ) - def list_memberships(self, - request: service.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsPager: + def list_memberships( + self, + request: service.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsPager: r"""Lists Memberships in a given project and location. Args: @@ -404,8 +423,10 @@ def list_memberships(self, # 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.') + 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.ListMembershipsRequest. @@ -425,39 +446,30 @@ def list_memberships(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListMembershipsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesPager: + def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: r"""Lists Features in a given project and location. Args: @@ -491,8 +503,10 @@ def list_features(self, # 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.') + 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.ListFeaturesRequest. @@ -512,39 +526,30 @@ def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - def get_membership(self, - request: service.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: + def get_membership( + self, + request: service.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: r"""Gets the details of a Membership. Args: @@ -575,8 +580,10 @@ def get_membership(self, # 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.') + 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.GetMembershipRequest. @@ -596,30 +603,24 @@ def get_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -650,8 +651,10 @@ def get_feature(self, # 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.') + 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.GetFeatureRequest. @@ -671,32 +674,26 @@ def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_membership(self, - request: service.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def create_membership( + self, + request: service.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Creates a new Membership. **This is currently only supported for GKE clusters on Google @@ -757,8 +754,10 @@ def create_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, membership_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.') + 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.CreateMembershipRequest. @@ -782,18 +781,11 @@ def create_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -806,16 +798,17 @@ def create_membership(self, # Done; return the response. return response - def create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Adds a new Feature. Args: @@ -860,8 +853,10 @@ def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.') + 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.CreateFeatureRequest. @@ -885,18 +880,11 @@ def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -909,14 +897,15 @@ def create_feature(self, # Done; return the response. return response - def delete_membership(self, - request: service.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def delete_membership( + self, + request: service.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Removes a Membership. **This is currently only supported for GKE clusters on Google @@ -965,8 +954,10 @@ def delete_membership(self, # 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.') + 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.DeleteMembershipRequest. @@ -986,18 +977,11 @@ def delete_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1010,14 +994,15 @@ def delete_membership(self, # Done; return the response. return response - def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Removes a Feature. Args: @@ -1061,8 +1046,10 @@ def delete_feature(self, # 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.') + 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.DeleteFeatureRequest. @@ -1082,18 +1069,11 @@ def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1106,16 +1086,17 @@ def delete_feature(self, # Done; return the response. return response - def update_membership(self, - request: service.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def update_membership( + self, + request: service.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Updates an existing Membership. Args: @@ -1168,8 +1149,10 @@ def update_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.') + 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.UpdateMembershipRequest. @@ -1193,18 +1176,11 @@ def update_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1217,16 +1193,17 @@ def update_membership(self, # Done; return the response. return response - def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Updates an existing Feature. Args: @@ -1279,8 +1256,10 @@ def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.') + 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.UpdateFeatureRequest. @@ -1304,18 +1283,11 @@ def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1328,13 +1300,14 @@ def update_feature(self, # Done; return the response. return response - def generate_connect_manifest(self, - request: service.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.GenerateConnectManifestResponse: + def generate_connect_manifest( + self, + request: service.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.GenerateConnectManifestResponse: r"""Generates the manifest for deployment of the GKE connect agent. **This method is used internally by Google-provided libraries.** @@ -1368,41 +1341,29 @@ def generate_connect_manifest(self, # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] + rpc = self._transport._wrapped_methods[ + self._transport.generate_connect_manifest + ] # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubClient", -) +__all__ = ("GkeHubClient",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py b/google/cloud/gkehub_v1/services/gke_hub/pagers.py similarity index 86% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py rename to google/cloud/gkehub_v1/services/gke_hub/pagers.py index 57d56bc..72da7bd 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/pagers.py +++ b/google/cloud/gkehub_v1/services/gke_hub/pagers.py @@ -13,7 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.gkehub_v1.types import feature from google.cloud.gkehub_v1.types import membership @@ -37,12 +46,15 @@ class ListMembershipsPager: 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.ListMembershipsResponse], - request: service.ListMembershipsRequest, - response: service.ListMembershipsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., service.ListMembershipsResponse], + request: service.ListMembershipsRequest, + response: service.ListMembershipsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiate the pager. Args: @@ -76,7 +88,7 @@ def __iter__(self) -> Iterable[membership.Membership]: yield from page.resources def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListMembershipsAsyncPager: @@ -96,12 +108,15 @@ class ListMembershipsAsyncPager: 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.ListMembershipsResponse]], - request: service.ListMembershipsRequest, - response: service.ListMembershipsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[service.ListMembershipsResponse]], + request: service.ListMembershipsRequest, + response: service.ListMembershipsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiates the pager. Args: @@ -139,7 +154,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListFeaturesPager: @@ -159,12 +174,15 @@ class ListFeaturesPager: 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.ListFeaturesResponse], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., service.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiate the pager. Args: @@ -198,7 +216,7 @@ def __iter__(self) -> Iterable[feature.Feature]: yield from page.resources def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListFeaturesAsyncPager: @@ -218,12 +236,15 @@ class ListFeaturesAsyncPager: 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.ListFeaturesResponse]], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[service.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiates the pager. Args: @@ -261,4 +282,4 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py similarity index 82% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py rename to google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py index 29c1c45..50e3055 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py @@ -23,11 +23,11 @@ # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry['grpc'] = GkeHubGrpcTransport -_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport +_transport_registry["grpc"] = GkeHubGrpcTransport +_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport __all__ = ( - 'GkeHubTransport', - 'GkeHubGrpcTransport', - 'GkeHubGrpcAsyncIOTransport', + "GkeHubTransport", + "GkeHubGrpcTransport", + "GkeHubGrpcAsyncIOTransport", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1/services/gke_hub/transports/base.py similarity index 56% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py rename to google/cloud/gkehub_v1/services/gke_hub/transports/base.py index 5b6c731..9b814e6 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/base.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/base.py @@ -21,11 +21,11 @@ import google.auth # type: ignore import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.gkehub_v1.types import feature from google.cloud.gkehub_v1.types import membership @@ -34,9 +34,7 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-gke-hub', - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -54,22 +52,22 @@ class GkeHubTransport(abc.ABC): """Abstract transport class for GkeHub.""" - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + DEFAULT_HOST: str = "gkehub.googleapis.com" - DEFAULT_HOST: str = 'gkehub.googleapis.com' def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: """Instantiate the transport. Args: @@ -95,8 +93,8 @@ def __init__( be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' + if ":" not in host: + host += ":443" self._host = host scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) @@ -107,20 +105,26 @@ def __init__( # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. @@ -132,7 +136,9 @@ def __init__( # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" scopes_kwargs = {} @@ -151,61 +157,41 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_memberships: gapic_v1.method.wrap_method( - self.list_memberships, - default_timeout=None, - client_info=client_info, + self.list_memberships, default_timeout=None, client_info=client_info, ), self.list_features: gapic_v1.method.wrap_method( - self.list_features, - default_timeout=None, - client_info=client_info, + self.list_features, default_timeout=None, client_info=client_info, ), self.get_membership: gapic_v1.method.wrap_method( - self.get_membership, - default_timeout=None, - client_info=client_info, + self.get_membership, default_timeout=None, client_info=client_info, ), self.get_feature: gapic_v1.method.wrap_method( - self.get_feature, - default_timeout=None, - client_info=client_info, + self.get_feature, default_timeout=None, client_info=client_info, ), self.create_membership: gapic_v1.method.wrap_method( - self.create_membership, - default_timeout=None, - client_info=client_info, + self.create_membership, default_timeout=None, client_info=client_info, ), self.create_feature: gapic_v1.method.wrap_method( - self.create_feature, - default_timeout=None, - client_info=client_info, + self.create_feature, default_timeout=None, client_info=client_info, ), self.delete_membership: gapic_v1.method.wrap_method( - self.delete_membership, - default_timeout=None, - client_info=client_info, + self.delete_membership, default_timeout=None, client_info=client_info, ), self.delete_feature: gapic_v1.method.wrap_method( - self.delete_feature, - default_timeout=None, - client_info=client_info, + self.delete_feature, default_timeout=None, client_info=client_info, ), self.update_membership: gapic_v1.method.wrap_method( - self.update_membership, - default_timeout=None, - client_info=client_info, + self.update_membership, default_timeout=None, client_info=client_info, ), self.update_feature: gapic_v1.method.wrap_method( - self.update_feature, - default_timeout=None, - client_info=client_info, + self.update_feature, default_timeout=None, client_info=client_info, ), self.generate_connect_manifest: gapic_v1.method.wrap_method( self.generate_connect_manifest, default_timeout=None, client_info=client_info, ), - } + } @property def operations_client(self) -> operations_v1.OperationsClient: @@ -213,105 +199,107 @@ def operations_client(self) -> operations_v1.OperationsClient: raise NotImplementedError() @property - def list_memberships(self) -> Callable[ - [service.ListMembershipsRequest], - Union[ - service.ListMembershipsResponse, - Awaitable[service.ListMembershipsResponse] - ]]: + def list_memberships( + self, + ) -> Callable[ + [service.ListMembershipsRequest], + Union[ + service.ListMembershipsResponse, Awaitable[service.ListMembershipsResponse] + ], + ]: raise NotImplementedError() @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Union[ - service.ListFeaturesResponse, - Awaitable[service.ListFeaturesResponse] - ]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], + Union[service.ListFeaturesResponse, Awaitable[service.ListFeaturesResponse]], + ]: raise NotImplementedError() @property - def get_membership(self) -> Callable[ - [service.GetMembershipRequest], - Union[ - membership.Membership, - Awaitable[membership.Membership] - ]]: + def get_membership( + self, + ) -> Callable[ + [service.GetMembershipRequest], + Union[membership.Membership, Awaitable[membership.Membership]], + ]: raise NotImplementedError() @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Union[ - feature.Feature, - Awaitable[feature.Feature] - ]]: + def get_feature( + self, + ) -> Callable[ + [service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]] + ]: raise NotImplementedError() @property - def create_membership(self) -> Callable[ - [service.CreateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def create_membership( + self, + ) -> Callable[ + [service.CreateMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def create_feature( + self, + ) -> Callable[ + [service.CreateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def delete_membership(self) -> Callable[ - [service.DeleteMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def delete_membership( + self, + ) -> Callable[ + [service.DeleteMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def delete_feature( + self, + ) -> Callable[ + [service.DeleteFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def update_membership(self) -> Callable[ - [service.UpdateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def update_membership( + self, + ) -> Callable[ + [service.UpdateMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def update_feature( + self, + ) -> Callable[ + [service.UpdateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def generate_connect_manifest(self) -> Callable[ - [service.GenerateConnectManifestRequest], - Union[ - service.GenerateConnectManifestResponse, - Awaitable[service.GenerateConnectManifestResponse] - ]]: + def generate_connect_manifest( + self, + ) -> Callable[ + [service.GenerateConnectManifestRequest], + Union[ + service.GenerateConnectManifestResponse, + Awaitable[service.GenerateConnectManifestResponse], + ], + ]: raise NotImplementedError() -__all__ = ( - 'GkeHubTransport', -) +__all__ = ("GkeHubTransport",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py similarity index 78% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py rename to google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py index 6866dd8..2b0dc56 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py @@ -16,10 +16,10 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore +from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -57,21 +57,24 @@ class GkeHubGrpcTransport(GkeHubTransport): It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """ + _stubs: Dict[str, Callable] - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -185,13 +188,15 @@ def __init__(self, *, self._prep_wrapped_messages(client_info) @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. @@ -226,7 +231,7 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) @property @@ -244,17 +249,15 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Sanity check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. return self._operations_client @property - def list_memberships(self) -> Callable[ - [service.ListMembershipsRequest], - service.ListMembershipsResponse]: + def list_memberships( + self, + ) -> Callable[[service.ListMembershipsRequest], service.ListMembershipsResponse]: r"""Return a callable for the list memberships method over gRPC. Lists Memberships in a given project and location. @@ -269,18 +272,18 @@ def list_memberships(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/ListMemberships', + if "list_memberships" not in self._stubs: + self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/ListMemberships", request_serializer=service.ListMembershipsRequest.serialize, response_deserializer=service.ListMembershipsResponse.deserialize, ) - return self._stubs['list_memberships'] + return self._stubs["list_memberships"] @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - service.ListFeaturesResponse]: + def list_features( + self, + ) -> Callable[[service.ListFeaturesRequest], service.ListFeaturesResponse]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -295,18 +298,18 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_membership(self) -> Callable[ - [service.GetMembershipRequest], - membership.Membership]: + def get_membership( + self, + ) -> Callable[[service.GetMembershipRequest], membership.Membership]: r"""Return a callable for the get membership method over gRPC. Gets the details of a Membership. @@ -321,18 +324,16 @@ def get_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GetMembership', + if "get_membership" not in self._stubs: + self._stubs["get_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GetMembership", request_serializer=service.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) - return self._stubs['get_membership'] + return self._stubs["get_membership"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - feature.Feature]: + def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -347,18 +348,18 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_membership(self) -> Callable[ - [service.CreateMembershipRequest], - operations_pb2.Operation]: + def create_membership( + self, + ) -> Callable[[service.CreateMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the create membership method over gRPC. Creates a new Membership. @@ -377,18 +378,18 @@ def create_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/CreateMembership', + if "create_membership" not in self._stubs: + self._stubs["create_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/CreateMembership", request_serializer=service.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_membership'] + return self._stubs["create_membership"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - operations_pb2.Operation]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -403,18 +404,18 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_membership(self) -> Callable[ - [service.DeleteMembershipRequest], - operations_pb2.Operation]: + def delete_membership( + self, + ) -> Callable[[service.DeleteMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the delete membership method over gRPC. Removes a Membership. @@ -434,18 +435,18 @@ def delete_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/DeleteMembership', + if "delete_membership" not in self._stubs: + self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/DeleteMembership", request_serializer=service.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_membership'] + return self._stubs["delete_membership"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - operations_pb2.Operation]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -460,18 +461,18 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_membership(self) -> Callable[ - [service.UpdateMembershipRequest], - operations_pb2.Operation]: + def update_membership( + self, + ) -> Callable[[service.UpdateMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the update membership method over gRPC. Updates an existing Membership. @@ -486,18 +487,18 @@ def update_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/UpdateMembership', + if "update_membership" not in self._stubs: + self._stubs["update_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/UpdateMembership", request_serializer=service.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_membership'] + return self._stubs["update_membership"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - operations_pb2.Operation]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -512,18 +513,21 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] @property - def generate_connect_manifest(self) -> Callable[ - [service.GenerateConnectManifestRequest], - service.GenerateConnectManifestResponse]: + def generate_connect_manifest( + self, + ) -> Callable[ + [service.GenerateConnectManifestRequest], + service.GenerateConnectManifestResponse, + ]: r"""Return a callable for the generate connect manifest method over gRPC. Generates the manifest for deployment of the GKE connect agent. @@ -541,15 +545,13 @@ def generate_connect_manifest(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest', + if "generate_connect_manifest" not in self._stubs: + self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest", request_serializer=service.GenerateConnectManifestRequest.serialize, response_deserializer=service.GenerateConnectManifestResponse.deserialize, ) - return self._stubs['generate_connect_manifest'] + return self._stubs["generate_connect_manifest"] -__all__ = ( - 'GkeHubGrpcTransport', -) +__all__ = ("GkeHubGrpcTransport",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py similarity index 77% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py rename to google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py index ad6ddc2..89cdc7e 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py @@ -16,14 +16,14 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import packaging.version -import grpc # type: ignore +import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.gkehub_v1.types import feature @@ -64,13 +64,15 @@ class GkeHubGrpcAsyncIOTransport(GkeHubTransport): _stubs: Dict[str, Callable] = {} @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. @@ -101,22 +103,24 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -256,9 +260,11 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: return self._operations_client @property - def list_memberships(self) -> Callable[ - [service.ListMembershipsRequest], - Awaitable[service.ListMembershipsResponse]]: + def list_memberships( + self, + ) -> Callable[ + [service.ListMembershipsRequest], Awaitable[service.ListMembershipsResponse] + ]: r"""Return a callable for the list memberships method over gRPC. Lists Memberships in a given project and location. @@ -273,18 +279,20 @@ def list_memberships(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/ListMemberships', + if "list_memberships" not in self._stubs: + self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/ListMemberships", request_serializer=service.ListMembershipsRequest.serialize, response_deserializer=service.ListMembershipsResponse.deserialize, ) - return self._stubs['list_memberships'] + return self._stubs["list_memberships"] @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Awaitable[service.ListFeaturesResponse]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], Awaitable[service.ListFeaturesResponse] + ]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -299,18 +307,18 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_membership(self) -> Callable[ - [service.GetMembershipRequest], - Awaitable[membership.Membership]]: + def get_membership( + self, + ) -> Callable[[service.GetMembershipRequest], Awaitable[membership.Membership]]: r"""Return a callable for the get membership method over gRPC. Gets the details of a Membership. @@ -325,18 +333,18 @@ def get_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GetMembership', + if "get_membership" not in self._stubs: + self._stubs["get_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GetMembership", request_serializer=service.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) - return self._stubs['get_membership'] + return self._stubs["get_membership"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Awaitable[feature.Feature]]: + def get_feature( + self, + ) -> Callable[[service.GetFeatureRequest], Awaitable[feature.Feature]]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -351,18 +359,20 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_membership(self) -> Callable[ - [service.CreateMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def create_membership( + self, + ) -> Callable[ + [service.CreateMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the create membership method over gRPC. Creates a new Membership. @@ -381,18 +391,18 @@ def create_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/CreateMembership', + if "create_membership" not in self._stubs: + self._stubs["create_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/CreateMembership", request_serializer=service.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_membership'] + return self._stubs["create_membership"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -407,18 +417,20 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_membership(self) -> Callable[ - [service.DeleteMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def delete_membership( + self, + ) -> Callable[ + [service.DeleteMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete membership method over gRPC. Removes a Membership. @@ -438,18 +450,18 @@ def delete_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/DeleteMembership', + if "delete_membership" not in self._stubs: + self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/DeleteMembership", request_serializer=service.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_membership'] + return self._stubs["delete_membership"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -464,18 +476,20 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_membership(self) -> Callable[ - [service.UpdateMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def update_membership( + self, + ) -> Callable[ + [service.UpdateMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update membership method over gRPC. Updates an existing Membership. @@ -490,18 +504,18 @@ def update_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/UpdateMembership', + if "update_membership" not in self._stubs: + self._stubs["update_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/UpdateMembership", request_serializer=service.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_membership'] + return self._stubs["update_membership"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -516,18 +530,21 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] @property - def generate_connect_manifest(self) -> Callable[ - [service.GenerateConnectManifestRequest], - Awaitable[service.GenerateConnectManifestResponse]]: + def generate_connect_manifest( + self, + ) -> Callable[ + [service.GenerateConnectManifestRequest], + Awaitable[service.GenerateConnectManifestResponse], + ]: r"""Return a callable for the generate connect manifest method over gRPC. Generates the manifest for deployment of the GKE connect agent. @@ -545,15 +562,13 @@ def generate_connect_manifest(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest', + if "generate_connect_manifest" not in self._stubs: + self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest", request_serializer=service.GenerateConnectManifestRequest.serialize, response_deserializer=service.GenerateConnectManifestResponse.deserialize, ) - return self._stubs['generate_connect_manifest'] + return self._stubs["generate_connect_manifest"] -__all__ = ( - 'GkeHubGrpcAsyncIOTransport', -) +__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py b/google/cloud/gkehub_v1/types/__init__.py similarity index 64% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py rename to google/cloud/gkehub_v1/types/__init__.py index e12ea53..daf8db4 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/__init__.py +++ b/google/cloud/gkehub_v1/types/__init__.py @@ -51,34 +51,34 @@ ) __all__ = ( - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'Authority', - 'GkeCluster', - 'KubernetesMetadata', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'ConnectAgentResource', - 'CreateFeatureRequest', - 'CreateMembershipRequest', - 'DeleteFeatureRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GetFeatureRequest', - 'GetMembershipRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'OperationMetadata', - 'TypeMeta', - 'UpdateFeatureRequest', - 'UpdateMembershipRequest', + "CommonFeatureSpec", + "CommonFeatureState", + "Feature", + "FeatureResourceState", + "FeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", + "Authority", + "GkeCluster", + "KubernetesMetadata", + "Membership", + "MembershipEndpoint", + "MembershipState", + "ConnectAgentResource", + "CreateFeatureRequest", + "CreateMembershipRequest", + "DeleteFeatureRequest", + "DeleteMembershipRequest", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "GetFeatureRequest", + "GetMembershipRequest", + "ListFeaturesRequest", + "ListFeaturesResponse", + "ListMembershipsRequest", + "ListMembershipsResponse", + "OperationMetadata", + "TypeMeta", + "UpdateFeatureRequest", + "UpdateMembershipRequest", ) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py b/google/cloud/gkehub_v1/types/feature.py similarity index 79% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py rename to google/cloud/gkehub_v1/types/feature.py index d9aea6e..f37caad 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/feature.py +++ b/google/cloud/gkehub_v1/types/feature.py @@ -21,15 +21,15 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1', + package="google.cloud.gkehub.v1", manifest={ - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', + "Feature", + "FeatureResourceState", + "FeatureState", + "CommonFeatureSpec", + "CommonFeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", }, ) @@ -97,56 +97,23 @@ class Feature(proto.Message): deleted. """ - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) resource_state = proto.Field( - proto.MESSAGE, - number=3, - message='FeatureResourceState', - ) - spec = proto.Field( - proto.MESSAGE, - number=4, - message='CommonFeatureSpec', + proto.MESSAGE, number=3, message="FeatureResourceState", ) + spec = proto.Field(proto.MESSAGE, number=4, message="CommonFeatureSpec",) membership_specs = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=5, - message='MembershipFeatureSpec', - ) - state = proto.Field( - proto.MESSAGE, - number=6, - message='CommonFeatureState', + proto.STRING, proto.MESSAGE, number=5, message="MembershipFeatureSpec", ) + state = proto.Field(proto.MESSAGE, number=6, message="CommonFeatureState",) membership_states = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=7, - message='MembershipFeatureState', - ) - create_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, + proto.STRING, proto.MESSAGE, number=7, message="MembershipFeatureState", ) + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) delete_time = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) @@ -160,6 +127,7 @@ class FeatureResourceState(proto.Message): The current state of the Feature resource in the Hub API. """ + class State(proto.Enum): r"""State describes the lifecycle status of a Feature.""" STATE_UNSPECIFIED = 0 @@ -169,11 +137,7 @@ class State(proto.Enum): UPDATING = 4 SERVICE_UPDATING = 5 - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) + state = proto.Field(proto.ENUM, number=1, enum=State,) class FeatureState(proto.Message): @@ -192,6 +156,7 @@ class FeatureState(proto.Message): The time this status and any related Feature- pecific details were updated. """ + class Code(proto.Enum): r"""Code represents a machine-readable, high-level status of the Feature. @@ -201,20 +166,9 @@ class Code(proto.Enum): WARNING = 2 ERROR = 3 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code,) + description = proto.Field(proto.STRING, number=2,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) class CommonFeatureSpec(proto.Message): @@ -227,7 +181,7 @@ class CommonFeatureSpec(proto.Message): multiclusteringress = proto.Field( proto.MESSAGE, number=102, - oneof='feature_spec', + oneof="feature_spec", message=multiclusteringress_pb2.FeatureSpec, ) @@ -242,11 +196,7 @@ class CommonFeatureState(proto.Message): Feature in this Hub. """ - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) class MembershipFeatureSpec(proto.Message): @@ -261,7 +211,7 @@ class MembershipFeatureSpec(proto.Message): configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_spec', + oneof="feature_spec", message=configmanagement_pb2.MembershipSpec, ) @@ -281,14 +231,10 @@ class MembershipFeatureState(proto.Message): configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_state', + oneof="feature_state", message=configmanagement_pb2.MembershipState, ) - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py b/google/cloud/gkehub_v1/types/membership.py similarity index 78% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py rename to google/cloud/gkehub_v1/types/membership.py index 147fd51..724751d 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/membership.py +++ b/google/cloud/gkehub_v1/types/membership.py @@ -19,14 +19,14 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1', + package="google.cloud.gkehub.v1", manifest={ - 'Membership', - 'MembershipEndpoint', - 'GkeCluster', - 'KubernetesMetadata', - 'MembershipState', - 'Authority', + "Membership", + "MembershipEndpoint", + "GkeCluster", + "KubernetesMetadata", + "MembershipState", + "Authority", }, ) @@ -105,62 +105,21 @@ class Membership(proto.Message): """ endpoint = proto.Field( - proto.MESSAGE, - number=4, - oneof='type', - message='MembershipEndpoint', - ) - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) - description = proto.Field( - proto.STRING, - number=3, - ) - state = proto.Field( - proto.MESSAGE, - number=5, - message='MembershipState', - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - external_id = proto.Field( - proto.STRING, - number=9, + proto.MESSAGE, number=4, oneof="type", message="MembershipEndpoint", ) + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) + state = proto.Field(proto.MESSAGE, number=5, message="MembershipState",) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + delete_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + external_id = proto.Field(proto.STRING, number=9,) last_connection_time = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, - ) - unique_id = proto.Field( - proto.STRING, - number=11, - ) - authority = proto.Field( - proto.MESSAGE, - number=12, - message='Authority', + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) + unique_id = proto.Field(proto.STRING, number=11,) + authority = proto.Field(proto.MESSAGE, number=12, message="Authority",) class MembershipEndpoint(proto.Message): @@ -176,15 +135,9 @@ class MembershipEndpoint(proto.Message): metadata. """ - gke_cluster = proto.Field( - proto.MESSAGE, - number=1, - message='GkeCluster', - ) + gke_cluster = proto.Field(proto.MESSAGE, number=1, message="GkeCluster",) kubernetes_metadata = proto.Field( - proto.MESSAGE, - number=2, - message='KubernetesMetadata', + proto.MESSAGE, number=2, message="KubernetesMetadata", ) @@ -199,10 +152,7 @@ class GkeCluster(proto.Message): Zonal clusters are also supported. """ - resource_link = proto.Field( - proto.STRING, - number=1, - ) + resource_link = proto.Field(proto.STRING, number=1,) class KubernetesMetadata(proto.Message): @@ -236,30 +186,13 @@ class KubernetesMetadata(proto.Message): updated internally for API consumers. """ - kubernetes_api_server_version = proto.Field( - proto.STRING, - number=1, - ) - node_provider_id = proto.Field( - proto.STRING, - number=2, - ) - node_count = proto.Field( - proto.INT32, - number=3, - ) - vcpu_count = proto.Field( - proto.INT32, - number=4, - ) - memory_mb = proto.Field( - proto.INT32, - number=5, - ) + kubernetes_api_server_version = proto.Field(proto.STRING, number=1,) + node_provider_id = proto.Field(proto.STRING, number=2,) + node_count = proto.Field(proto.INT32, number=3,) + vcpu_count = proto.Field(proto.INT32, number=4,) + memory_mb = proto.Field(proto.INT32, number=5,) update_time = proto.Field( - proto.MESSAGE, - number=100, - message=timestamp_pb2.Timestamp, + proto.MESSAGE, number=100, message=timestamp_pb2.Timestamp, ) @@ -270,6 +203,7 @@ class MembershipState(proto.Message): Output only. The current state of the Membership resource. """ + class Code(proto.Enum): r"""Code describes the state of a Membership resource.""" CODE_UNSPECIFIED = 0 @@ -279,11 +213,7 @@ class Code(proto.Enum): UPDATING = 4 SERVICE_UPDATING = 5 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code,) class Authority(proto.Message): @@ -328,22 +258,10 @@ class Authority(proto.Message): using this field. """ - issuer = proto.Field( - proto.STRING, - number=1, - ) - workload_identity_pool = proto.Field( - proto.STRING, - number=2, - ) - identity_provider = proto.Field( - proto.STRING, - number=3, - ) - oidc_jwks = proto.Field( - proto.BYTES, - number=4, - ) + issuer = proto.Field(proto.STRING, number=1,) + workload_identity_pool = proto.Field(proto.STRING, number=2,) + identity_provider = proto.Field(proto.STRING, number=3,) + oidc_jwks = proto.Field(proto.BYTES, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py b/google/cloud/gkehub_v1/types/service.py similarity index 79% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py rename to google/cloud/gkehub_v1/types/service.py index d777913..6fcd1ff 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/types/service.py +++ b/google/cloud/gkehub_v1/types/service.py @@ -22,25 +22,25 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1', + package="google.cloud.gkehub.v1", manifest={ - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'GetMembershipRequest', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'UpdateMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'ConnectAgentResource', - 'TypeMeta', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'GetFeatureRequest', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'UpdateFeatureRequest', - 'OperationMetadata', + "ListMembershipsRequest", + "ListMembershipsResponse", + "GetMembershipRequest", + "CreateMembershipRequest", + "DeleteMembershipRequest", + "UpdateMembershipRequest", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "ConnectAgentResource", + "TypeMeta", + "ListFeaturesRequest", + "ListFeaturesResponse", + "GetFeatureRequest", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "UpdateFeatureRequest", + "OperationMetadata", }, ) @@ -91,26 +91,11 @@ class ListMembershipsRequest(proto.Message): https://google.aip.dev/132#ordering. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListMembershipsResponse(proto.Message): @@ -132,18 +117,10 @@ def raw_page(self): return self resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=membership.Membership, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, + proto.MESSAGE, number=1, message=membership.Membership, ) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class GetMembershipRequest(proto.Message): @@ -154,10 +131,7 @@ class GetMembershipRequest(proto.Message): ``projects/*/locations/*/memberships/*``. """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class CreateMembershipRequest(proto.Message): @@ -202,23 +176,10 @@ class CreateMembershipRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field( - proto.STRING, - number=1, - ) - membership_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=membership.Membership, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1,) + membership_id = proto.Field(proto.STRING, number=2,) + resource = proto.Field(proto.MESSAGE, number=3, message=membership.Membership,) + request_id = proto.Field(proto.STRING, number=4,) class DeleteMembershipRequest(proto.Message): @@ -247,14 +208,8 @@ class DeleteMembershipRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class UpdateMembershipRequest(proto.Message): @@ -294,24 +249,12 @@ class UpdateMembershipRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=membership.Membership, - ) - request_id = proto.Field( - proto.STRING, - number=4, + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) + resource = proto.Field(proto.MESSAGE, number=3, message=membership.Membership,) + request_id = proto.Field(proto.STRING, number=4,) class GenerateConnectManifestRequest(proto.Message): @@ -350,34 +293,13 @@ class GenerateConnectManifestRequest(proto.Message): the registry, if not public. """ - name = proto.Field( - proto.STRING, - number=1, - ) - namespace = proto.Field( - proto.STRING, - number=2, - ) - proxy = proto.Field( - proto.BYTES, - number=3, - ) - version = proto.Field( - proto.STRING, - number=4, - ) - is_upgrade = proto.Field( - proto.BOOL, - number=5, - ) - registry = proto.Field( - proto.STRING, - number=6, - ) - image_pull_secret_content = proto.Field( - proto.BYTES, - number=7, - ) + name = proto.Field(proto.STRING, number=1,) + namespace = proto.Field(proto.STRING, number=2,) + proxy = proto.Field(proto.BYTES, number=3,) + version = proto.Field(proto.STRING, number=4,) + is_upgrade = proto.Field(proto.BOOL, number=5,) + registry = proto.Field(proto.STRING, number=6,) + image_pull_secret_content = proto.Field(proto.BYTES, number=7,) class GenerateConnectManifestResponse(proto.Message): @@ -392,9 +314,7 @@ class GenerateConnectManifestResponse(proto.Message): """ manifest = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ConnectAgentResource', + proto.MESSAGE, number=1, message="ConnectAgentResource", ) @@ -409,15 +329,8 @@ class ConnectAgentResource(proto.Message): YAML manifest of the resource. """ - type_ = proto.Field( - proto.MESSAGE, - number=1, - message='TypeMeta', - ) - manifest = proto.Field( - proto.STRING, - number=2, - ) + type_ = proto.Field(proto.MESSAGE, number=1, message="TypeMeta",) + manifest = proto.Field(proto.STRING, number=2,) class TypeMeta(proto.Message): @@ -431,14 +344,8 @@ class TypeMeta(proto.Message): APIVersion of the resource (e.g. v1). """ - kind = proto.Field( - proto.STRING, - number=1, - ) - api_version = proto.Field( - proto.STRING, - number=2, - ) + kind = proto.Field(proto.STRING, number=1,) + api_version = proto.Field(proto.STRING, number=2,) class ListFeaturesRequest(proto.Message): @@ -481,26 +388,11 @@ class ListFeaturesRequest(proto.Message): https://google.aip.dev/132#ordering. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListFeaturesResponse(proto.Message): @@ -518,15 +410,8 @@ class ListFeaturesResponse(proto.Message): def raw_page(self): return self - resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=feature.Feature, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + resources = proto.RepeatedField(proto.MESSAGE, number=1, message=feature.Feature,) + next_page_token = proto.Field(proto.STRING, number=2,) class GetFeatureRequest(proto.Message): @@ -537,10 +422,7 @@ class GetFeatureRequest(proto.Message): ``projects/*/locations/*/features/*`` """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class CreateFeatureRequest(proto.Message): @@ -573,23 +455,10 @@ class CreateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field( - proto.STRING, - number=1, - ) - feature_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1,) + feature_id = proto.Field(proto.STRING, number=2,) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class DeleteFeatureRequest(proto.Message): @@ -623,18 +492,9 @@ class DeleteFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) - force = proto.Field( - proto.BOOL, - number=2, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) + request_id = proto.Field(proto.STRING, number=3,) class UpdateFeatureRequest(proto.Message): @@ -674,24 +534,12 @@ class UpdateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class OperationMetadata(proto.Message): @@ -723,36 +571,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_detail = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_detail = proto.Field(proto.STRING, number=5,) + cancel_requested = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py b/google/cloud/gkehub_v1alpha/__init__.py similarity index 76% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py rename to google/cloud/gkehub_v1alpha/__init__.py index fe33a01..dcb311b 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/__init__.py +++ b/google/cloud/gkehub_v1alpha/__init__.py @@ -33,20 +33,20 @@ from .types.service import UpdateFeatureRequest __all__ = ( - 'GkeHubAsyncClient', -'CommonFeatureSpec', -'CommonFeatureState', -'CreateFeatureRequest', -'DeleteFeatureRequest', -'Feature', -'FeatureResourceState', -'FeatureState', -'GetFeatureRequest', -'GkeHubClient', -'ListFeaturesRequest', -'ListFeaturesResponse', -'MembershipFeatureSpec', -'MembershipFeatureState', -'OperationMetadata', -'UpdateFeatureRequest', + "GkeHubAsyncClient", + "CommonFeatureSpec", + "CommonFeatureState", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "Feature", + "FeatureResourceState", + "FeatureState", + "GetFeatureRequest", + "GkeHubClient", + "ListFeaturesRequest", + "ListFeaturesResponse", + "MembershipFeatureSpec", + "MembershipFeatureState", + "OperationMetadata", + "UpdateFeatureRequest", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json b/google/cloud/gkehub_v1alpha/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/gapic_metadata.json rename to google/cloud/gkehub_v1alpha/gapic_metadata.json diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed b/google/cloud/gkehub_v1alpha/py.typed similarity index 100% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/py.typed rename to google/cloud/gkehub_v1alpha/py.typed diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py b/google/cloud/gkehub_v1alpha/services/__init__.py similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/services/__init__.py rename to google/cloud/gkehub_v1alpha/services/__init__.py diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py b/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py similarity index 93% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py index 7304648..73e44b4 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py @@ -17,6 +17,6 @@ from .async_client import GkeHubAsyncClient __all__ = ( - 'GkeHubClient', - 'GkeHubAsyncClient', + "GkeHubClient", + "GkeHubAsyncClient", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py b/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py index e5ef4fe..c4398cf 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py @@ -19,12 +19,12 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -64,11 +64,15 @@ class GkeHubAsyncClient: feature_path = staticmethod(GkeHubClient.feature_path) parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + parse_common_billing_account_path = staticmethod( + GkeHubClient.parse_common_billing_account_path + ) common_folder_path = staticmethod(GkeHubClient.common_folder_path) parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + parse_common_organization_path = staticmethod( + GkeHubClient.parse_common_organization_path + ) common_project_path = staticmethod(GkeHubClient.common_project_path) parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) common_location_path = staticmethod(GkeHubClient.common_location_path) @@ -116,14 +120,18 @@ def transport(self) -> GkeHubTransport: """ return self._client.transport - get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + get_transport_class = functools.partial( + type(GkeHubClient).get_transport_class, type(GkeHubClient) + ) - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -161,17 +169,17 @@ def __init__(self, *, transport=transport, client_options=client_options, client_info=client_info, - ) - async def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesAsyncPager: + async def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: r"""Lists Features in a given project and location. Args: @@ -205,8 +213,10 @@ async def list_features(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.ListFeaturesRequest(request) @@ -226,39 +236,30 @@ async def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - async def get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + async def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -289,8 +290,10 @@ async def get_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.GetFeatureRequest(request) @@ -310,32 +313,26 @@ async def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Adds a new Feature. Args: @@ -381,8 +378,10 @@ async def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.CreateFeatureRequest(request) @@ -406,18 +405,11 @@ async def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -430,14 +422,15 @@ async def create_feature(self, # Done; return the response. return response - async def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Removes a Feature. Args: @@ -481,8 +474,10 @@ async def delete_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.DeleteFeatureRequest(request) @@ -502,18 +497,11 @@ async def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -526,16 +514,17 @@ async def delete_feature(self, # Done; return the response. return response - async def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Updates an existing Feature. Args: @@ -589,8 +578,10 @@ async def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.UpdateFeatureRequest(request) @@ -614,18 +605,11 @@ async def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -639,19 +623,12 @@ async def update_feature(self, return response - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubAsyncClient", -) +__all__ = ("GkeHubAsyncClient",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py b/google/cloud/gkehub_v1alpha/services/gke_hub/client.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/client.py index f90e0a2..d034fea 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/client.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/client.py @@ -21,14 +21,14 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -50,13 +50,12 @@ class GkeHubClientMeta(type): support objects (e.g. transport) without polluting the client instance objects. """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] _transport_registry["grpc"] = GkeHubGrpcTransport _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - def get_transport_class(cls, - label: str = None, - ) -> Type[GkeHubTransport]: + def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: """Returns an appropriate transport class. Args: @@ -158,8 +157,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: GkeHubClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) + credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs) @@ -176,77 +174,88 @@ def transport(self) -> GkeHubTransport: return self._transport @staticmethod - def feature_path(project: str,location: str,feature: str,) -> str: + def feature_path(project: str, location: str, feature: str,) -> str: """Returns a fully-qualified feature string.""" - return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + return "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) @staticmethod - def parse_feature_path(path: str) -> Dict[str,str]: + def parse_feature_path(path: str) -> Dict[str, str]: """Parses a feature path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: + def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: + def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P.+?)$", path) 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]: + def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P.+?)$", path) 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]: + def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P.+?)$", path) 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]: + def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P.+?)$", path) 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, ) + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: + def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -290,7 +299,9 @@ def __init__(self, *, client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + use_client_cert = bool( + util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + ) client_cert_source_func = None is_mtls = False @@ -331,8 +342,10 @@ def __init__(self, *, if isinstance(transport, GkeHubTransport): # transport is a GkeHubTransport instance. if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) if client_options.scopes: raise ValueError( "When providing a transport instance, provide its scopes " @@ -351,14 +364,15 @@ def __init__(self, *, client_info=client_info, ) - def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesPager: + def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: r"""Lists Features in a given project and location. Args: @@ -392,8 +406,10 @@ def list_features(self, # 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.') + 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.ListFeaturesRequest. @@ -413,39 +429,30 @@ def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - def get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -476,8 +483,10 @@ def get_feature(self, # 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.') + 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.GetFeatureRequest. @@ -497,32 +506,26 @@ def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Adds a new Feature. Args: @@ -568,8 +571,10 @@ def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.') + 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.CreateFeatureRequest. @@ -593,18 +598,11 @@ def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -617,14 +615,15 @@ def create_feature(self, # Done; return the response. return response - def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Removes a Feature. Args: @@ -668,8 +667,10 @@ def delete_feature(self, # 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.') + 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.DeleteFeatureRequest. @@ -689,18 +690,11 @@ def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -713,16 +707,17 @@ def delete_feature(self, # Done; return the response. return response - def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Updates an existing Feature. Args: @@ -776,8 +771,10 @@ def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.') + 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.UpdateFeatureRequest. @@ -801,18 +798,11 @@ def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -826,19 +816,12 @@ def update_feature(self, return response - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubClient", -) +__all__ = ("GkeHubClient",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py b/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py similarity index 86% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py index 71573d9..fba47dc 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py @@ -13,7 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.gkehub_v1alpha.types import feature from google.cloud.gkehub_v1alpha.types import service @@ -36,12 +45,15 @@ class ListFeaturesPager: 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.ListFeaturesResponse], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., service.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiate the pager. Args: @@ -75,7 +87,7 @@ def __iter__(self) -> Iterable[feature.Feature]: yield from page.resources def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListFeaturesAsyncPager: @@ -95,12 +107,15 @@ class ListFeaturesAsyncPager: 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.ListFeaturesResponse]], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[service.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiates the pager. Args: @@ -138,4 +153,4 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py similarity index 82% rename from owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py index 29c1c45..50e3055 100644 --- a/owl-bot-staging/v1/google/cloud/gkehub_v1/services/gke_hub/transports/__init__.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py @@ -23,11 +23,11 @@ # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry['grpc'] = GkeHubGrpcTransport -_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport +_transport_registry["grpc"] = GkeHubGrpcTransport +_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport __all__ = ( - 'GkeHubTransport', - 'GkeHubGrpcTransport', - 'GkeHubGrpcAsyncIOTransport', + "GkeHubTransport", + "GkeHubGrpcTransport", + "GkeHubGrpcAsyncIOTransport", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py similarity index 64% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py index 00e3c20..6bfc639 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py @@ -21,11 +21,11 @@ import google.auth # type: ignore import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.gkehub_v1alpha.types import feature from google.cloud.gkehub_v1alpha.types import service @@ -33,9 +33,7 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-gke-hub', - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -53,22 +51,22 @@ class GkeHubTransport(abc.ABC): """Abstract transport class for GkeHub.""" - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + DEFAULT_HOST: str = "gkehub.googleapis.com" - DEFAULT_HOST: str = 'gkehub.googleapis.com' def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: """Instantiate the transport. Args: @@ -94,8 +92,8 @@ def __init__( be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' + if ":" not in host: + host += ":443" self._host = host scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) @@ -106,20 +104,26 @@ def __init__( # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. @@ -131,7 +135,9 @@ def __init__( # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" scopes_kwargs = {} @@ -150,31 +156,21 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_features: gapic_v1.method.wrap_method( - self.list_features, - default_timeout=None, - client_info=client_info, + self.list_features, default_timeout=None, client_info=client_info, ), self.get_feature: gapic_v1.method.wrap_method( - self.get_feature, - default_timeout=None, - client_info=client_info, + self.get_feature, default_timeout=None, client_info=client_info, ), self.create_feature: gapic_v1.method.wrap_method( - self.create_feature, - default_timeout=None, - client_info=client_info, + self.create_feature, default_timeout=None, client_info=client_info, ), self.delete_feature: gapic_v1.method.wrap_method( - self.delete_feature, - default_timeout=None, - client_info=client_info, + self.delete_feature, default_timeout=None, client_info=client_info, ), self.update_feature: gapic_v1.method.wrap_method( - self.update_feature, - default_timeout=None, - client_info=client_info, + self.update_feature, default_timeout=None, client_info=client_info, ), - } + } @property def operations_client(self) -> operations_v1.OperationsClient: @@ -182,51 +178,48 @@ def operations_client(self) -> operations_v1.OperationsClient: raise NotImplementedError() @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Union[ - service.ListFeaturesResponse, - Awaitable[service.ListFeaturesResponse] - ]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], + Union[service.ListFeaturesResponse, Awaitable[service.ListFeaturesResponse]], + ]: raise NotImplementedError() @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Union[ - feature.Feature, - Awaitable[feature.Feature] - ]]: + def get_feature( + self, + ) -> Callable[ + [service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]] + ]: raise NotImplementedError() @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def create_feature( + self, + ) -> Callable[ + [service.CreateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def delete_feature( + self, + ) -> Callable[ + [service.DeleteFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def update_feature( + self, + ) -> Callable[ + [service.UpdateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() -__all__ = ( - 'GkeHubTransport', -) +__all__ = ("GkeHubTransport",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py index 546f6be..ddbe160 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py @@ -16,10 +16,10 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore +from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -56,21 +56,24 @@ class GkeHubGrpcTransport(GkeHubTransport): It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """ + _stubs: Dict[str, Callable] - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -184,13 +187,15 @@ def __init__(self, *, self._prep_wrapped_messages(client_info) @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. @@ -225,7 +230,7 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) @property @@ -243,17 +248,15 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Sanity check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. return self._operations_client @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - service.ListFeaturesResponse]: + def list_features( + self, + ) -> Callable[[service.ListFeaturesRequest], service.ListFeaturesResponse]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -268,18 +271,16 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - feature.Feature]: + def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -294,18 +295,18 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - operations_pb2.Operation]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -320,18 +321,18 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - operations_pb2.Operation]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -346,18 +347,18 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - operations_pb2.Operation]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -372,15 +373,13 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] -__all__ = ( - 'GkeHubGrpcTransport', -) +__all__ = ("GkeHubGrpcTransport",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py rename to google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py index 91c5359..0b09308 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py @@ -16,14 +16,14 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import packaging.version -import grpc # type: ignore +import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.gkehub_v1alpha.types import feature @@ -63,13 +63,15 @@ class GkeHubGrpcAsyncIOTransport(GkeHubTransport): _stubs: Dict[str, Callable] = {} @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. @@ -100,22 +102,24 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -255,9 +259,11 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: return self._operations_client @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Awaitable[service.ListFeaturesResponse]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], Awaitable[service.ListFeaturesResponse] + ]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -272,18 +278,18 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Awaitable[feature.Feature]]: + def get_feature( + self, + ) -> Callable[[service.GetFeatureRequest], Awaitable[feature.Feature]]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -298,18 +304,18 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -324,18 +330,18 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -350,18 +356,18 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -376,15 +382,13 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] -__all__ = ( - 'GkeHubGrpcAsyncIOTransport', -) +__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py b/google/cloud/gkehub_v1alpha/types/__init__.py similarity index 73% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py rename to google/cloud/gkehub_v1alpha/types/__init__.py index 09483e1..f966a52 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/__init__.py +++ b/google/cloud/gkehub_v1alpha/types/__init__.py @@ -33,18 +33,18 @@ ) __all__ = ( - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'GetFeatureRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'OperationMetadata', - 'UpdateFeatureRequest', + "CommonFeatureSpec", + "CommonFeatureState", + "Feature", + "FeatureResourceState", + "FeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "GetFeatureRequest", + "ListFeaturesRequest", + "ListFeaturesResponse", + "OperationMetadata", + "UpdateFeatureRequest", ) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py b/google/cloud/gkehub_v1alpha/types/feature.py similarity index 81% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py rename to google/cloud/gkehub_v1alpha/types/feature.py index a751f2f..c387abb 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/feature.py +++ b/google/cloud/gkehub_v1alpha/types/feature.py @@ -24,15 +24,15 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1alpha', + package="google.cloud.gkehub.v1alpha", manifest={ - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', + "Feature", + "FeatureResourceState", + "FeatureState", + "CommonFeatureSpec", + "CommonFeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", }, ) @@ -100,56 +100,23 @@ class Feature(proto.Message): deleted. """ - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) resource_state = proto.Field( - proto.MESSAGE, - number=3, - message='FeatureResourceState', - ) - spec = proto.Field( - proto.MESSAGE, - number=4, - message='CommonFeatureSpec', + proto.MESSAGE, number=3, message="FeatureResourceState", ) + spec = proto.Field(proto.MESSAGE, number=4, message="CommonFeatureSpec",) membership_specs = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=5, - message='MembershipFeatureSpec', - ) - state = proto.Field( - proto.MESSAGE, - number=6, - message='CommonFeatureState', + proto.STRING, proto.MESSAGE, number=5, message="MembershipFeatureSpec", ) + state = proto.Field(proto.MESSAGE, number=6, message="CommonFeatureState",) membership_states = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=7, - message='MembershipFeatureState', - ) - create_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, + proto.STRING, proto.MESSAGE, number=7, message="MembershipFeatureState", ) + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) delete_time = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) @@ -163,6 +130,7 @@ class FeatureResourceState(proto.Message): The current state of the Feature resource in the Hub API. """ + class State(proto.Enum): r"""State describes the lifecycle status of a Feature.""" STATE_UNSPECIFIED = 0 @@ -172,11 +140,7 @@ class State(proto.Enum): UPDATING = 4 SERVICE_UPDATING = 5 - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) + state = proto.Field(proto.ENUM, number=1, enum=State,) class FeatureState(proto.Message): @@ -195,6 +159,7 @@ class FeatureState(proto.Message): The time this status and any related Feature- pecific details were updated. """ + class Code(proto.Enum): r"""Code represents a machine-readable, high-level status of the Feature. @@ -204,20 +169,9 @@ class Code(proto.Enum): WARNING = 2 ERROR = 3 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code,) + description = proto.Field(proto.STRING, number=2,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) class CommonFeatureSpec(proto.Message): @@ -232,13 +186,13 @@ class CommonFeatureSpec(proto.Message): multiclusteringress = proto.Field( proto.MESSAGE, number=102, - oneof='feature_spec', + oneof="feature_spec", message=multiclusteringress_pb2.FeatureSpec, ) cloudauditlogging = proto.Field( proto.MESSAGE, number=108, - oneof='feature_spec', + oneof="feature_spec", message=cloudauditlogging_pb2.FeatureSpec, ) @@ -258,14 +212,10 @@ class CommonFeatureState(proto.Message): servicemesh = proto.Field( proto.MESSAGE, number=100, - oneof='feature_state', + oneof="feature_state", message=servicemesh_pb2.FeatureState, ) - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) class MembershipFeatureSpec(proto.Message): @@ -280,7 +230,7 @@ class MembershipFeatureSpec(proto.Message): configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_spec', + oneof="feature_spec", message=configmanagement_pb2.MembershipSpec, ) @@ -304,26 +254,22 @@ class MembershipFeatureState(proto.Message): servicemesh = proto.Field( proto.MESSAGE, number=100, - oneof='feature_state', + oneof="feature_state", message=servicemesh_pb2.MembershipState, ) metering = proto.Field( proto.MESSAGE, number=104, - oneof='feature_state', + oneof="feature_state", message=metering_pb2.MembershipState, ) configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_state', + oneof="feature_state", message=configmanagement_pb2.MembershipState, ) - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py b/google/cloud/gkehub_v1alpha/types/service.py similarity index 79% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py rename to google/cloud/gkehub_v1alpha/types/service.py index 179ce0c..cdc402b 100644 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/types/service.py +++ b/google/cloud/gkehub_v1alpha/types/service.py @@ -21,15 +21,15 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1alpha', + package="google.cloud.gkehub.v1alpha", manifest={ - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'GetFeatureRequest', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'UpdateFeatureRequest', - 'OperationMetadata', + "ListFeaturesRequest", + "ListFeaturesResponse", + "GetFeatureRequest", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "UpdateFeatureRequest", + "OperationMetadata", }, ) @@ -74,26 +74,11 @@ class ListFeaturesRequest(proto.Message): https://google.aip.dev/132#ordering. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListFeaturesResponse(proto.Message): @@ -111,15 +96,8 @@ class ListFeaturesResponse(proto.Message): def raw_page(self): return self - resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=feature.Feature, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + resources = proto.RepeatedField(proto.MESSAGE, number=1, message=feature.Feature,) + next_page_token = proto.Field(proto.STRING, number=2,) class GetFeatureRequest(proto.Message): @@ -130,10 +108,7 @@ class GetFeatureRequest(proto.Message): ``projects/*/locations/*/features/*`` """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class CreateFeatureRequest(proto.Message): @@ -166,23 +141,10 @@ class CreateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field( - proto.STRING, - number=1, - ) - feature_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1,) + feature_id = proto.Field(proto.STRING, number=2,) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class DeleteFeatureRequest(proto.Message): @@ -216,18 +178,9 @@ class DeleteFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) - force = proto.Field( - proto.BOOL, - number=2, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) + request_id = proto.Field(proto.STRING, number=3,) class UpdateFeatureRequest(proto.Message): @@ -267,24 +220,12 @@ class UpdateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class OperationMetadata(proto.Message): @@ -316,36 +257,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_detail = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_detail = proto.Field(proto.STRING, number=5,) + cancel_requested = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py b/google/cloud/gkehub_v1alpha2/__init__.py similarity index 74% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py rename to google/cloud/gkehub_v1alpha2/__init__.py index 42b9ecb..3e4cc54 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/__init__.py +++ b/google/cloud/gkehub_v1alpha2/__init__.py @@ -41,28 +41,28 @@ from .types.membership import UpdateMembershipRequest __all__ = ( - 'GkeHubAsyncClient', -'Authority', -'ConnectAgentResource', -'CreateMembershipRequest', -'DeleteMembershipRequest', -'GenerateConnectManifestRequest', -'GenerateConnectManifestResponse', -'GetMembershipRequest', -'GkeCluster', -'GkeHubClient', -'InitializeHubRequest', -'InitializeHubResponse', -'KubernetesMetadata', -'KubernetesResource', -'ListMembershipsRequest', -'ListMembershipsResponse', -'Membership', -'MembershipEndpoint', -'MembershipState', -'OperationMetadata', -'ResourceManifest', -'ResourceOptions', -'TypeMeta', -'UpdateMembershipRequest', + "GkeHubAsyncClient", + "Authority", + "ConnectAgentResource", + "CreateMembershipRequest", + "DeleteMembershipRequest", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "GetMembershipRequest", + "GkeCluster", + "GkeHubClient", + "InitializeHubRequest", + "InitializeHubResponse", + "KubernetesMetadata", + "KubernetesResource", + "ListMembershipsRequest", + "ListMembershipsResponse", + "Membership", + "MembershipEndpoint", + "MembershipState", + "OperationMetadata", + "ResourceManifest", + "ResourceOptions", + "TypeMeta", + "UpdateMembershipRequest", ) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json b/google/cloud/gkehub_v1alpha2/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/gapic_metadata.json rename to google/cloud/gkehub_v1alpha2/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed b/google/cloud/gkehub_v1alpha2/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub/py.typed rename to google/cloud/gkehub_v1alpha2/py.typed diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py b/google/cloud/gkehub_v1alpha2/services/__init__.py similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py rename to google/cloud/gkehub_v1alpha2/services/__init__.py diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py similarity index 93% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py index 7304648..73e44b4 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py @@ -17,6 +17,6 @@ from .async_client import GkeHubAsyncClient __all__ = ( - 'GkeHubClient', - 'GkeHubAsyncClient', + "GkeHubClient", + "GkeHubAsyncClient", ) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py similarity index 79% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py index b68a10b..1173261 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py @@ -19,12 +19,12 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -52,11 +52,15 @@ class GkeHubAsyncClient: membership_path = staticmethod(GkeHubClient.membership_path) parse_membership_path = staticmethod(GkeHubClient.parse_membership_path) common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + parse_common_billing_account_path = staticmethod( + GkeHubClient.parse_common_billing_account_path + ) common_folder_path = staticmethod(GkeHubClient.common_folder_path) parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + parse_common_organization_path = staticmethod( + GkeHubClient.parse_common_organization_path + ) common_project_path = staticmethod(GkeHubClient.common_project_path) parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) common_location_path = staticmethod(GkeHubClient.common_location_path) @@ -104,14 +108,18 @@ def transport(self) -> GkeHubTransport: """ return self._client.transport - get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + get_transport_class = functools.partial( + type(GkeHubClient).get_transport_class, type(GkeHubClient) + ) - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -149,17 +157,17 @@ def __init__(self, *, transport=transport, client_options=client_options, client_info=client_info, - ) - async def list_memberships(self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsAsyncPager: + async def list_memberships( + self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsAsyncPager: r"""Lists Memberships in a given project and location. Args: @@ -193,8 +201,10 @@ async def list_memberships(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = membership.ListMembershipsRequest(request) @@ -214,39 +224,30 @@ async def list_memberships(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListMembershipsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - async def get_membership(self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: + async def get_membership( + self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: r"""Gets the details of a Membership. Args: @@ -277,8 +278,10 @@ async def get_membership(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = membership.GetMembershipRequest(request) @@ -298,32 +301,26 @@ async def get_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_membership(self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def create_membership( + self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Adds a new Membership. Args: @@ -380,8 +377,10 @@ async def create_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, membership_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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = membership.CreateMembershipRequest(request) @@ -405,18 +404,11 @@ async def create_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -429,14 +421,15 @@ async def create_membership(self, # Done; return the response. return response - async def delete_membership(self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def delete_membership( + self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Removes a Membership. Args: @@ -480,8 +473,10 @@ async def delete_membership(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = membership.DeleteMembershipRequest(request) @@ -501,18 +496,11 @@ async def delete_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -525,16 +513,17 @@ async def delete_membership(self, # Done; return the response. return response - async def update_membership(self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def update_membership( + self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Updates an existing Membership. Args: @@ -585,8 +574,10 @@ async def update_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = membership.UpdateMembershipRequest(request) @@ -610,18 +601,11 @@ async def update_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -634,13 +618,14 @@ async def update_membership(self, # Done; return the response. return response - async def generate_connect_manifest(self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: + async def generate_connect_manifest( + self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: r"""Generates the manifest for deployment of the GKE connect agent. @@ -676,29 +661,23 @@ async def generate_connect_manifest(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 initialize_hub(self, - request: membership.InitializeHubRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.InitializeHubResponse: + async def initialize_hub( + self, + request: membership.InitializeHubRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.InitializeHubResponse: r"""Initializes the Hub in this project, which includes creating the default Hub Service Account and the Hub Workload Identity Pool. Initialization is optional, and @@ -740,36 +719,22 @@ async def initialize_hub(self, # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project", request.project), - )), + gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)), ) # 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 - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubAsyncClient", -) +__all__ = ("GkeHubAsyncClient",) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py similarity index 80% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/client.py index 280eb7c..7e5bc3e 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py @@ -21,14 +21,14 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -49,13 +49,12 @@ class GkeHubClientMeta(type): support objects (e.g. transport) without polluting the client instance objects. """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] _transport_registry["grpc"] = GkeHubGrpcTransport _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - def get_transport_class(cls, - label: str = None, - ) -> Type[GkeHubTransport]: + def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: """Returns an appropriate transport class. Args: @@ -146,8 +145,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: GkeHubClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) + credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs) @@ -164,77 +162,88 @@ def transport(self) -> GkeHubTransport: return self._transport @staticmethod - def membership_path(project: str,location: str,membership: str,) -> str: + def membership_path(project: str, location: str, membership: str,) -> str: """Returns a fully-qualified membership string.""" - return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + return "projects/{project}/locations/{location}/memberships/{membership}".format( + project=project, location=location, membership=membership, + ) @staticmethod - def parse_membership_path(path: str) -> Dict[str,str]: + def parse_membership_path(path: str) -> Dict[str, str]: """Parses a membership path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: + def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: + def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P.+?)$", path) 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]: + def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P.+?)$", path) 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]: + def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P.+?)$", path) 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]: + def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P.+?)$", path) 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, ) + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: + def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -278,7 +287,9 @@ def __init__(self, *, client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + use_client_cert = bool( + util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + ) client_cert_source_func = None is_mtls = False @@ -319,8 +330,10 @@ def __init__(self, *, if isinstance(transport, GkeHubTransport): # transport is a GkeHubTransport instance. if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) if client_options.scopes: raise ValueError( "When providing a transport instance, provide its scopes " @@ -339,14 +352,15 @@ def __init__(self, *, client_info=client_info, ) - def list_memberships(self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsPager: + def list_memberships( + self, + request: membership.ListMembershipsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMembershipsPager: r"""Lists Memberships in a given project and location. Args: @@ -380,8 +394,10 @@ def list_memberships(self, # 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.') + 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 membership.ListMembershipsRequest. @@ -401,39 +417,30 @@ def list_memberships(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListMembershipsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - def get_membership(self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: + def get_membership( + self, + request: membership.GetMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.Membership: r"""Gets the details of a Membership. Args: @@ -464,8 +471,10 @@ def get_membership(self, # 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.') + 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 membership.GetMembershipRequest. @@ -485,32 +494,26 @@ def get_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_membership(self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def create_membership( + self, + request: membership.CreateMembershipRequest = None, + *, + parent: str = None, + resource: membership.Membership = None, + membership_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Adds a new Membership. Args: @@ -567,8 +570,10 @@ def create_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, membership_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.') + 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 membership.CreateMembershipRequest. @@ -592,18 +597,11 @@ def create_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -616,14 +614,15 @@ def create_membership(self, # Done; return the response. return response - def delete_membership(self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def delete_membership( + self, + request: membership.DeleteMembershipRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Removes a Membership. Args: @@ -667,8 +666,10 @@ def delete_membership(self, # 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.') + 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 membership.DeleteMembershipRequest. @@ -688,18 +689,11 @@ def delete_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -712,16 +706,17 @@ def delete_membership(self, # Done; return the response. return response - def update_membership(self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def update_membership( + self, + request: membership.UpdateMembershipRequest = None, + *, + name: str = None, + resource: membership.Membership = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Updates an existing Membership. Args: @@ -772,8 +767,10 @@ def update_membership(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.') + 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 membership.UpdateMembershipRequest. @@ -797,18 +794,11 @@ def update_membership(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -821,13 +811,14 @@ def update_membership(self, # Done; return the response. return response - def generate_connect_manifest(self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: + def generate_connect_manifest( + self, + request: membership.GenerateConnectManifestRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.GenerateConnectManifestResponse: r"""Generates the manifest for deployment of the GKE connect agent. @@ -859,34 +850,30 @@ def generate_connect_manifest(self, # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] + rpc = self._transport._wrapped_methods[ + self._transport.generate_connect_manifest + ] # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 initialize_hub(self, - request: membership.InitializeHubRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.InitializeHubResponse: + def initialize_hub( + self, + request: membership.InitializeHubRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> membership.InitializeHubResponse: r"""Initializes the Hub in this project, which includes creating the default Hub Service Account and the Hub Workload Identity Pool. Initialization is optional, and @@ -929,36 +916,22 @@ def initialize_hub(self, # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project", request.project), - )), + gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)), ) # 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 - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubClient", -) +__all__ = ("GkeHubClient",) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py similarity index 85% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py index 3467a04..aa11653 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py @@ -13,7 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.gkehub_v1alpha2.types import membership @@ -35,12 +44,15 @@ class ListMembershipsPager: 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[..., membership.ListMembershipsResponse], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., membership.ListMembershipsResponse], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiate the pager. Args: @@ -74,7 +86,7 @@ def __iter__(self) -> Iterable[membership.Membership]: yield from page.resources def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListMembershipsAsyncPager: @@ -94,12 +106,15 @@ class ListMembershipsAsyncPager: 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[membership.ListMembershipsResponse]], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[membership.ListMembershipsResponse]], + request: membership.ListMembershipsRequest, + response: membership.ListMembershipsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiates the pager. Args: @@ -137,4 +152,4 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py similarity index 82% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py index 29c1c45..50e3055 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py @@ -23,11 +23,11 @@ # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry['grpc'] = GkeHubGrpcTransport -_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport +_transport_registry["grpc"] = GkeHubGrpcTransport +_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport __all__ = ( - 'GkeHubTransport', - 'GkeHubGrpcTransport', - 'GkeHubGrpcAsyncIOTransport', + "GkeHubTransport", + "GkeHubGrpcTransport", + "GkeHubGrpcAsyncIOTransport", ) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py similarity index 60% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py index 128d108..eafe685 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py @@ -21,20 +21,18 @@ import google.auth # type: ignore import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.gkehub_v1alpha2.types import membership from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-gke-hub', - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -52,22 +50,22 @@ class GkeHubTransport(abc.ABC): """Abstract transport class for GkeHub.""" - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + DEFAULT_HOST: str = "gkehub.googleapis.com" - DEFAULT_HOST: str = 'gkehub.googleapis.com' def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: """Instantiate the transport. Args: @@ -93,8 +91,8 @@ def __init__( be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' + if ":" not in host: + host += ":443" self._host = host scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) @@ -105,20 +103,26 @@ def __init__( # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. @@ -130,7 +134,9 @@ def __init__( # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" scopes_kwargs = {} @@ -149,29 +155,19 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_memberships: gapic_v1.method.wrap_method( - self.list_memberships, - default_timeout=None, - client_info=client_info, + self.list_memberships, default_timeout=None, client_info=client_info, ), self.get_membership: gapic_v1.method.wrap_method( - self.get_membership, - default_timeout=None, - client_info=client_info, + self.get_membership, default_timeout=None, client_info=client_info, ), self.create_membership: gapic_v1.method.wrap_method( - self.create_membership, - default_timeout=None, - client_info=client_info, + self.create_membership, default_timeout=None, client_info=client_info, ), self.delete_membership: gapic_v1.method.wrap_method( - self.delete_membership, - default_timeout=None, - client_info=client_info, + self.delete_membership, default_timeout=None, client_info=client_info, ), self.update_membership: gapic_v1.method.wrap_method( - self.update_membership, - default_timeout=None, - client_info=client_info, + self.update_membership, default_timeout=None, client_info=client_info, ), self.generate_connect_manifest: gapic_v1.method.wrap_method( self.generate_connect_manifest, @@ -179,11 +175,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.initialize_hub: gapic_v1.method.wrap_method( - self.initialize_hub, - default_timeout=None, - client_info=client_info, + self.initialize_hub, default_timeout=None, client_info=client_info, ), - } + } @property def operations_client(self) -> operations_v1.OperationsClient: @@ -191,69 +185,76 @@ def operations_client(self) -> operations_v1.OperationsClient: raise NotImplementedError() @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - Union[ - membership.ListMembershipsResponse, - Awaitable[membership.ListMembershipsResponse] - ]]: + def list_memberships( + self, + ) -> Callable[ + [membership.ListMembershipsRequest], + Union[ + membership.ListMembershipsResponse, + Awaitable[membership.ListMembershipsResponse], + ], + ]: raise NotImplementedError() @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - Union[ - membership.Membership, - Awaitable[membership.Membership] - ]]: + def get_membership( + self, + ) -> Callable[ + [membership.GetMembershipRequest], + Union[membership.Membership, Awaitable[membership.Membership]], + ]: raise NotImplementedError() @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def create_membership( + self, + ) -> Callable[ + [membership.CreateMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def delete_membership( + self, + ) -> Callable[ + [membership.DeleteMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def update_membership( + self, + ) -> Callable[ + [membership.UpdateMembershipRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - Union[ - membership.GenerateConnectManifestResponse, - Awaitable[membership.GenerateConnectManifestResponse] - ]]: + def generate_connect_manifest( + self, + ) -> Callable[ + [membership.GenerateConnectManifestRequest], + Union[ + membership.GenerateConnectManifestResponse, + Awaitable[membership.GenerateConnectManifestResponse], + ], + ]: raise NotImplementedError() @property - def initialize_hub(self) -> Callable[ - [membership.InitializeHubRequest], - Union[ - membership.InitializeHubResponse, - Awaitable[membership.InitializeHubResponse] - ]]: + def initialize_hub( + self, + ) -> Callable[ + [membership.InitializeHubRequest], + Union[ + membership.InitializeHubResponse, + Awaitable[membership.InitializeHubResponse], + ], + ]: raise NotImplementedError() -__all__ = ( - 'GkeHubTransport', -) +__all__ = ("GkeHubTransport",) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py similarity index 79% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py index c8a7903..d096b4f 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py @@ -16,10 +16,10 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore +from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -44,21 +44,24 @@ class GkeHubGrpcTransport(GkeHubTransport): It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """ + _stubs: Dict[str, Callable] - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -172,13 +175,15 @@ def __init__(self, *, self._prep_wrapped_messages(client_info) @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. @@ -213,7 +218,7 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) @property @@ -231,17 +236,17 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Sanity check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. return self._operations_client @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - membership.ListMembershipsResponse]: + def list_memberships( + self, + ) -> Callable[ + [membership.ListMembershipsRequest], membership.ListMembershipsResponse + ]: r"""Return a callable for the list memberships method over gRPC. Lists Memberships in a given project and location. @@ -256,18 +261,18 @@ def list_memberships(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships', + if "list_memberships" not in self._stubs: + self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships", request_serializer=membership.ListMembershipsRequest.serialize, response_deserializer=membership.ListMembershipsResponse.deserialize, ) - return self._stubs['list_memberships'] + return self._stubs["list_memberships"] @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - membership.Membership]: + def get_membership( + self, + ) -> Callable[[membership.GetMembershipRequest], membership.Membership]: r"""Return a callable for the get membership method over gRPC. Gets the details of a Membership. @@ -282,18 +287,18 @@ def get_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership', + if "get_membership" not in self._stubs: + self._stubs["get_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership", request_serializer=membership.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) - return self._stubs['get_membership'] + return self._stubs["get_membership"] @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - operations_pb2.Operation]: + def create_membership( + self, + ) -> Callable[[membership.CreateMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the create membership method over gRPC. Adds a new Membership. @@ -308,18 +313,18 @@ def create_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership', + if "create_membership" not in self._stubs: + self._stubs["create_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership", request_serializer=membership.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_membership'] + return self._stubs["create_membership"] @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - operations_pb2.Operation]: + def delete_membership( + self, + ) -> Callable[[membership.DeleteMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the delete membership method over gRPC. Removes a Membership. @@ -334,18 +339,18 @@ def delete_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership', + if "delete_membership" not in self._stubs: + self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership", request_serializer=membership.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_membership'] + return self._stubs["delete_membership"] @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - operations_pb2.Operation]: + def update_membership( + self, + ) -> Callable[[membership.UpdateMembershipRequest], operations_pb2.Operation]: r"""Return a callable for the update membership method over gRPC. Updates an existing Membership. @@ -360,18 +365,21 @@ def update_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership', + if "update_membership" not in self._stubs: + self._stubs["update_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership", request_serializer=membership.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_membership'] + return self._stubs["update_membership"] @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - membership.GenerateConnectManifestResponse]: + def generate_connect_manifest( + self, + ) -> Callable[ + [membership.GenerateConnectManifestRequest], + membership.GenerateConnectManifestResponse, + ]: r"""Return a callable for the generate connect manifest method over gRPC. Generates the manifest for deployment of the GKE @@ -387,18 +395,18 @@ def generate_connect_manifest(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest', + if "generate_connect_manifest" not in self._stubs: + self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest", request_serializer=membership.GenerateConnectManifestRequest.serialize, response_deserializer=membership.GenerateConnectManifestResponse.deserialize, ) - return self._stubs['generate_connect_manifest'] + return self._stubs["generate_connect_manifest"] @property - def initialize_hub(self) -> Callable[ - [membership.InitializeHubRequest], - membership.InitializeHubResponse]: + def initialize_hub( + self, + ) -> Callable[[membership.InitializeHubRequest], membership.InitializeHubResponse]: r"""Return a callable for the initialize hub method over gRPC. Initializes the Hub in this project, which includes @@ -422,15 +430,13 @@ def initialize_hub(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'initialize_hub' not in self._stubs: - self._stubs['initialize_hub'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub', + if "initialize_hub" not in self._stubs: + self._stubs["initialize_hub"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub", request_serializer=membership.InitializeHubRequest.serialize, response_deserializer=membership.InitializeHubResponse.deserialize, ) - return self._stubs['initialize_hub'] + return self._stubs["initialize_hub"] -__all__ = ( - 'GkeHubGrpcTransport', -) +__all__ = ("GkeHubGrpcTransport",) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py similarity index 78% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py rename to google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py index 7b5d4d3..2089383 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py @@ -16,14 +16,14 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import packaging.version -import grpc # type: ignore +import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.gkehub_v1alpha2.types import membership @@ -51,13 +51,15 @@ class GkeHubGrpcAsyncIOTransport(GkeHubTransport): _stubs: Dict[str, Callable] = {} @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. @@ -88,22 +90,24 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -243,9 +247,12 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: return self._operations_client @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - Awaitable[membership.ListMembershipsResponse]]: + def list_memberships( + self, + ) -> Callable[ + [membership.ListMembershipsRequest], + Awaitable[membership.ListMembershipsResponse], + ]: r"""Return a callable for the list memberships method over gRPC. Lists Memberships in a given project and location. @@ -260,18 +267,18 @@ def list_memberships(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships', + if "list_memberships" not in self._stubs: + self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships", request_serializer=membership.ListMembershipsRequest.serialize, response_deserializer=membership.ListMembershipsResponse.deserialize, ) - return self._stubs['list_memberships'] + return self._stubs["list_memberships"] @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - Awaitable[membership.Membership]]: + def get_membership( + self, + ) -> Callable[[membership.GetMembershipRequest], Awaitable[membership.Membership]]: r"""Return a callable for the get membership method over gRPC. Gets the details of a Membership. @@ -286,18 +293,20 @@ def get_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership', + if "get_membership" not in self._stubs: + self._stubs["get_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership", request_serializer=membership.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) - return self._stubs['get_membership'] + return self._stubs["get_membership"] @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def create_membership( + self, + ) -> Callable[ + [membership.CreateMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the create membership method over gRPC. Adds a new Membership. @@ -312,18 +321,20 @@ def create_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership', + if "create_membership" not in self._stubs: + self._stubs["create_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership", request_serializer=membership.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_membership'] + return self._stubs["create_membership"] @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def delete_membership( + self, + ) -> Callable[ + [membership.DeleteMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete membership method over gRPC. Removes a Membership. @@ -338,18 +349,20 @@ def delete_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership', + if "delete_membership" not in self._stubs: + self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership", request_serializer=membership.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_membership'] + return self._stubs["delete_membership"] @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - Awaitable[operations_pb2.Operation]]: + def update_membership( + self, + ) -> Callable[ + [membership.UpdateMembershipRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update membership method over gRPC. Updates an existing Membership. @@ -364,18 +377,21 @@ def update_membership(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership', + if "update_membership" not in self._stubs: + self._stubs["update_membership"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership", request_serializer=membership.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_membership'] + return self._stubs["update_membership"] @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - Awaitable[membership.GenerateConnectManifestResponse]]: + def generate_connect_manifest( + self, + ) -> Callable[ + [membership.GenerateConnectManifestRequest], + Awaitable[membership.GenerateConnectManifestResponse], + ]: r"""Return a callable for the generate connect manifest method over gRPC. Generates the manifest for deployment of the GKE @@ -391,18 +407,20 @@ def generate_connect_manifest(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest', + if "generate_connect_manifest" not in self._stubs: + self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest", request_serializer=membership.GenerateConnectManifestRequest.serialize, response_deserializer=membership.GenerateConnectManifestResponse.deserialize, ) - return self._stubs['generate_connect_manifest'] + return self._stubs["generate_connect_manifest"] @property - def initialize_hub(self) -> Callable[ - [membership.InitializeHubRequest], - Awaitable[membership.InitializeHubResponse]]: + def initialize_hub( + self, + ) -> Callable[ + [membership.InitializeHubRequest], Awaitable[membership.InitializeHubResponse] + ]: r"""Return a callable for the initialize hub method over gRPC. Initializes the Hub in this project, which includes @@ -426,15 +444,13 @@ def initialize_hub(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'initialize_hub' not in self._stubs: - self._stubs['initialize_hub'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub', + if "initialize_hub" not in self._stubs: + self._stubs["initialize_hub"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub", request_serializer=membership.InitializeHubRequest.serialize, response_deserializer=membership.InitializeHubResponse.deserialize, ) - return self._stubs['initialize_hub'] + return self._stubs["initialize_hub"] -__all__ = ( - 'GkeHubGrpcAsyncIOTransport', -) +__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py b/google/cloud/gkehub_v1alpha2/types/__init__.py similarity index 66% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py rename to google/cloud/gkehub_v1alpha2/types/__init__.py index 92abd8e..d9d1009 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/__init__.py +++ b/google/cloud/gkehub_v1alpha2/types/__init__.py @@ -39,26 +39,26 @@ ) __all__ = ( - 'Authority', - 'ConnectAgentResource', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GetMembershipRequest', - 'GkeCluster', - 'InitializeHubRequest', - 'InitializeHubResponse', - 'KubernetesMetadata', - 'KubernetesResource', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'OperationMetadata', - 'ResourceManifest', - 'ResourceOptions', - 'TypeMeta', - 'UpdateMembershipRequest', + "Authority", + "ConnectAgentResource", + "CreateMembershipRequest", + "DeleteMembershipRequest", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "GetMembershipRequest", + "GkeCluster", + "InitializeHubRequest", + "InitializeHubResponse", + "KubernetesMetadata", + "KubernetesResource", + "ListMembershipsRequest", + "ListMembershipsResponse", + "Membership", + "MembershipEndpoint", + "MembershipState", + "OperationMetadata", + "ResourceManifest", + "ResourceOptions", + "TypeMeta", + "UpdateMembershipRequest", ) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py b/google/cloud/gkehub_v1alpha2/types/membership.py similarity index 77% rename from owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py rename to google/cloud/gkehub_v1alpha2/types/membership.py index cf34a7e..ceb6d4a 100644 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/types/membership.py +++ b/google/cloud/gkehub_v1alpha2/types/membership.py @@ -20,30 +20,30 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1alpha2', + package="google.cloud.gkehub.v1alpha2", manifest={ - 'Membership', - 'MembershipEndpoint', - 'KubernetesResource', - 'ResourceOptions', - 'GkeCluster', - 'KubernetesMetadata', - 'Authority', - 'MembershipState', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'GetMembershipRequest', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'UpdateMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'ConnectAgentResource', - 'ResourceManifest', - 'TypeMeta', - 'InitializeHubRequest', - 'InitializeHubResponse', - 'OperationMetadata', + "Membership", + "MembershipEndpoint", + "KubernetesResource", + "ResourceOptions", + "GkeCluster", + "KubernetesMetadata", + "Authority", + "MembershipState", + "ListMembershipsRequest", + "ListMembershipsResponse", + "GetMembershipRequest", + "CreateMembershipRequest", + "DeleteMembershipRequest", + "UpdateMembershipRequest", + "GenerateConnectManifestRequest", + "GenerateConnectManifestResponse", + "ConnectAgentResource", + "ResourceManifest", + "TypeMeta", + "InitializeHubRequest", + "InitializeHubResponse", + "OperationMetadata", }, ) @@ -124,6 +124,7 @@ class Membership(proto.Message): Optional. The infrastructure type this Membership is running on. """ + class InfrastructureType(proto.Enum): r"""Specifies the infrastructure type of a Membership. Infrastructure type is used by Hub to control infrastructure- @@ -136,68 +137,23 @@ class InfrastructureType(proto.Enum): ON_PREM = 1 MULTI_CLOUD = 2 - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) - description = proto.Field( - proto.STRING, - number=3, - ) + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) endpoint = proto.Field( - proto.MESSAGE, - number=4, - oneof='type', - message='MembershipEndpoint', - ) - state = proto.Field( - proto.MESSAGE, - number=5, - message='MembershipState', - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - external_id = proto.Field( - proto.STRING, - number=9, - ) - authority = proto.Field( - proto.MESSAGE, - number=10, - message='Authority', - ) + proto.MESSAGE, number=4, oneof="type", message="MembershipEndpoint", + ) + state = proto.Field(proto.MESSAGE, number=5, message="MembershipState",) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + delete_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + external_id = proto.Field(proto.STRING, number=9,) + authority = proto.Field(proto.MESSAGE, number=10, message="Authority",) last_connection_time = proto.Field( - proto.MESSAGE, - number=11, - message=timestamp_pb2.Timestamp, - ) - unique_id = proto.Field( - proto.STRING, - number=12, - ) - infrastructure_type = proto.Field( - proto.ENUM, - number=13, - enum=InfrastructureType, + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, ) + unique_id = proto.Field(proto.STRING, number=12,) + infrastructure_type = proto.Field(proto.ENUM, number=13, enum=InfrastructureType,) class MembershipEndpoint(proto.Message): @@ -224,20 +180,12 @@ class MembershipEndpoint(proto.Message): Features. """ - gke_cluster = proto.Field( - proto.MESSAGE, - number=1, - message='GkeCluster', - ) + gke_cluster = proto.Field(proto.MESSAGE, number=1, message="GkeCluster",) kubernetes_metadata = proto.Field( - proto.MESSAGE, - number=2, - message='KubernetesMetadata', + proto.MESSAGE, number=2, message="KubernetesMetadata", ) kubernetes_resource = proto.Field( - proto.MESSAGE, - number=3, - message='KubernetesResource', + proto.MESSAGE, number=3, message="KubernetesResource", ) @@ -285,25 +233,14 @@ class KubernetesResource(proto.Message): generation. """ - membership_cr_manifest = proto.Field( - proto.STRING, - number=1, - ) + membership_cr_manifest = proto.Field(proto.STRING, number=1,) membership_resources = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ResourceManifest', + proto.MESSAGE, number=3, message="ResourceManifest", ) connect_resources = proto.RepeatedField( - proto.MESSAGE, - number=4, - message='ResourceManifest', - ) - resource_options = proto.Field( - proto.MESSAGE, - number=5, - message='ResourceOptions', + proto.MESSAGE, number=4, message="ResourceManifest", ) + resource_options = proto.Field(proto.MESSAGE, number=5, message="ResourceOptions",) class ResourceOptions(proto.Message): @@ -323,14 +260,8 @@ class ResourceOptions(proto.Message): apiserver versions <1.16. """ - connect_version = proto.Field( - proto.STRING, - number=1, - ) - v1beta1_crd = proto.Field( - proto.BOOL, - number=2, - ) + connect_version = proto.Field(proto.STRING, number=1,) + v1beta1_crd = proto.Field(proto.BOOL, number=2,) class GkeCluster(proto.Message): @@ -344,10 +275,7 @@ class GkeCluster(proto.Message): Zonal clusters are also supported. """ - resource_link = proto.Field( - proto.STRING, - number=1, - ) + resource_link = proto.Field(proto.STRING, number=1,) class KubernetesMetadata(proto.Message): @@ -382,30 +310,13 @@ class KubernetesMetadata(proto.Message): updated internally for API consumers. """ - kubernetes_api_server_version = proto.Field( - proto.STRING, - number=1, - ) - node_provider_id = proto.Field( - proto.STRING, - number=2, - ) - node_count = proto.Field( - proto.INT32, - number=3, - ) - vcpu_count = proto.Field( - proto.INT32, - number=4, - ) - memory_mb = proto.Field( - proto.INT32, - number=5, - ) + kubernetes_api_server_version = proto.Field(proto.STRING, number=1,) + node_provider_id = proto.Field(proto.STRING, number=2,) + node_count = proto.Field(proto.INT32, number=3,) + vcpu_count = proto.Field(proto.INT32, number=4,) + memory_mb = proto.Field(proto.INT32, number=5,) update_time = proto.Field( - proto.MESSAGE, - number=100, - message=timestamp_pb2.Timestamp, + proto.MESSAGE, number=100, message=timestamp_pb2.Timestamp, ) @@ -451,22 +362,10 @@ class Authority(proto.Message): change in newer versions of this API. """ - issuer = proto.Field( - proto.STRING, - number=1, - ) - oidc_jwks = proto.Field( - proto.BYTES, - number=5, - ) - identity_provider = proto.Field( - proto.STRING, - number=3, - ) - workload_identity_pool = proto.Field( - proto.STRING, - number=4, - ) + issuer = proto.Field(proto.STRING, number=1,) + oidc_jwks = proto.Field(proto.BYTES, number=5,) + identity_provider = proto.Field(proto.STRING, number=3,) + workload_identity_pool = proto.Field(proto.STRING, number=4,) class MembershipState(proto.Message): @@ -476,6 +375,7 @@ class MembershipState(proto.Message): Output only. The current state of the Membership resource. """ + class Code(proto.Enum): r"""Code describes the state of a Membership resource.""" CODE_UNSPECIFIED = 0 @@ -485,11 +385,7 @@ class Code(proto.Enum): UPDATING = 4 SERVICE_UPDATING = 5 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code,) class ListMembershipsRequest(proto.Message): @@ -538,26 +434,11 @@ class ListMembershipsRequest(proto.Message): https://google.aip.dev/132#ordering. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListMembershipsResponse(proto.Message): @@ -578,19 +459,9 @@ class ListMembershipsResponse(proto.Message): def raw_page(self): return self - resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Membership', - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) + resources = proto.RepeatedField(proto.MESSAGE, number=1, message="Membership",) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class GetMembershipRequest(proto.Message): @@ -601,10 +472,7 @@ class GetMembershipRequest(proto.Message): ``projects/*/locations/*/memberships/*``. """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class CreateMembershipRequest(proto.Message): @@ -631,19 +499,9 @@ class CreateMembershipRequest(proto.Message): Required. The membership to create. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - membership_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message='Membership', - ) + parent = proto.Field(proto.STRING, number=1,) + membership_id = proto.Field(proto.STRING, number=2,) + resource = proto.Field(proto.MESSAGE, number=3, message="Membership",) class DeleteMembershipRequest(proto.Message): @@ -654,10 +512,7 @@ class DeleteMembershipRequest(proto.Message): ``projects/*/locations/*/memberships/*``. """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class UpdateMembershipRequest(proto.Message): @@ -677,20 +532,11 @@ class UpdateMembershipRequest(proto.Message): possible to update a key's value to the empty string. """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message='Membership', + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) + resource = proto.Field(proto.MESSAGE, number=3, message="Membership",) class GenerateConnectManifestRequest(proto.Message): @@ -729,34 +575,13 @@ class GenerateConnectManifestRequest(proto.Message): the registry, if not public. """ - name = proto.Field( - proto.STRING, - number=1, - ) - namespace = proto.Field( - proto.STRING, - number=2, - ) - proxy = proto.Field( - proto.BYTES, - number=3, - ) - version = proto.Field( - proto.STRING, - number=4, - ) - is_upgrade = proto.Field( - proto.BOOL, - number=5, - ) - registry = proto.Field( - proto.STRING, - number=6, - ) - image_pull_secret_content = proto.Field( - proto.BYTES, - number=7, - ) + name = proto.Field(proto.STRING, number=1,) + namespace = proto.Field(proto.STRING, number=2,) + proxy = proto.Field(proto.BYTES, number=3,) + version = proto.Field(proto.STRING, number=4,) + is_upgrade = proto.Field(proto.BOOL, number=5,) + registry = proto.Field(proto.STRING, number=6,) + image_pull_secret_content = proto.Field(proto.BYTES, number=7,) class GenerateConnectManifestResponse(proto.Message): @@ -771,9 +596,7 @@ class GenerateConnectManifestResponse(proto.Message): """ manifest = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ConnectAgentResource', + proto.MESSAGE, number=1, message="ConnectAgentResource", ) @@ -788,15 +611,8 @@ class ConnectAgentResource(proto.Message): YAML manifest of the resource. """ - type_ = proto.Field( - proto.MESSAGE, - number=1, - message='TypeMeta', - ) - manifest = proto.Field( - proto.STRING, - number=2, - ) + type_ = proto.Field(proto.MESSAGE, number=1, message="TypeMeta",) + manifest = proto.Field(proto.STRING, number=2,) class ResourceManifest(proto.Message): @@ -815,14 +631,8 @@ class ResourceManifest(proto.Message): resource in a cluster. """ - manifest = proto.Field( - proto.STRING, - number=1, - ) - cluster_scoped = proto.Field( - proto.BOOL, - number=2, - ) + manifest = proto.Field(proto.STRING, number=1,) + cluster_scoped = proto.Field(proto.BOOL, number=2,) class TypeMeta(proto.Message): @@ -836,14 +646,8 @@ class TypeMeta(proto.Message): APIVersion of the resource (e.g. v1). """ - kind = proto.Field( - proto.STRING, - number=1, - ) - api_version = proto.Field( - proto.STRING, - number=2, - ) + kind = proto.Field(proto.STRING, number=1,) + api_version = proto.Field(proto.STRING, number=2,) class InitializeHubRequest(proto.Message): @@ -854,10 +658,7 @@ class InitializeHubRequest(proto.Message): ``projects/*/locations/*/memberships/*``. """ - project = proto.Field( - proto.STRING, - number=1, - ) + project = proto.Field(proto.STRING, number=1,) class InitializeHubResponse(proto.Message): @@ -878,14 +679,8 @@ class InitializeHubResponse(proto.Message): ``.hub.id.goog`` """ - service_identity = proto.Field( - proto.STRING, - number=1, - ) - workload_identity_pool = proto.Field( - proto.STRING, - number=2, - ) + service_identity = proto.Field(proto.STRING, number=1,) + workload_identity_pool = proto.Field(proto.STRING, number=2,) class OperationMetadata(proto.Message): @@ -917,36 +712,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_detail = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_detail = proto.Field(proto.STRING, number=5,) + cancel_requested = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py b/google/cloud/gkehub_v1beta/__init__.py similarity index 76% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py rename to google/cloud/gkehub_v1beta/__init__.py index fe33a01..dcb311b 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/__init__.py +++ b/google/cloud/gkehub_v1beta/__init__.py @@ -33,20 +33,20 @@ from .types.service import UpdateFeatureRequest __all__ = ( - 'GkeHubAsyncClient', -'CommonFeatureSpec', -'CommonFeatureState', -'CreateFeatureRequest', -'DeleteFeatureRequest', -'Feature', -'FeatureResourceState', -'FeatureState', -'GetFeatureRequest', -'GkeHubClient', -'ListFeaturesRequest', -'ListFeaturesResponse', -'MembershipFeatureSpec', -'MembershipFeatureState', -'OperationMetadata', -'UpdateFeatureRequest', + "GkeHubAsyncClient", + "CommonFeatureSpec", + "CommonFeatureState", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "Feature", + "FeatureResourceState", + "FeatureState", + "GetFeatureRequest", + "GkeHubClient", + "ListFeaturesRequest", + "ListFeaturesResponse", + "MembershipFeatureSpec", + "MembershipFeatureState", + "OperationMetadata", + "UpdateFeatureRequest", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json b/google/cloud/gkehub_v1beta/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/gapic_metadata.json rename to google/cloud/gkehub_v1beta/gapic_metadata.json diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed b/google/cloud/gkehub_v1beta/py.typed similarity index 100% rename from owl-bot-staging/v1alpha/google/cloud/gkehub_v1alpha/py.typed rename to google/cloud/gkehub_v1beta/py.typed diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py b/google/cloud/gkehub_v1beta/services/__init__.py similarity index 100% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/__init__.py rename to google/cloud/gkehub_v1beta/services/__init__.py diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py b/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py similarity index 93% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py rename to google/cloud/gkehub_v1beta/services/gke_hub/__init__.py index 7304648..73e44b4 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py @@ -17,6 +17,6 @@ from .async_client import GkeHubAsyncClient __all__ = ( - 'GkeHubClient', - 'GkeHubAsyncClient', + "GkeHubClient", + "GkeHubAsyncClient", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py b/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py rename to google/cloud/gkehub_v1beta/services/gke_hub/async_client.py index e0ac435..ad47b41 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py @@ -19,12 +19,12 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -64,11 +64,15 @@ class GkeHubAsyncClient: feature_path = staticmethod(GkeHubClient.feature_path) parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(GkeHubClient.parse_common_billing_account_path) + parse_common_billing_account_path = staticmethod( + GkeHubClient.parse_common_billing_account_path + ) common_folder_path = staticmethod(GkeHubClient.common_folder_path) parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod(GkeHubClient.parse_common_organization_path) + parse_common_organization_path = staticmethod( + GkeHubClient.parse_common_organization_path + ) common_project_path = staticmethod(GkeHubClient.common_project_path) parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) common_location_path = staticmethod(GkeHubClient.common_location_path) @@ -116,14 +120,18 @@ def transport(self) -> GkeHubTransport: """ return self._client.transport - get_transport_class = functools.partial(type(GkeHubClient).get_transport_class, type(GkeHubClient)) + get_transport_class = functools.partial( + type(GkeHubClient).get_transport_class, type(GkeHubClient) + ) - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, GkeHubTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -161,17 +169,17 @@ def __init__(self, *, transport=transport, client_options=client_options, client_info=client_info, - ) - async def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesAsyncPager: + async def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesAsyncPager: r"""Lists Features in a given project and location. Args: @@ -205,8 +213,10 @@ async def list_features(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.ListFeaturesRequest(request) @@ -226,39 +236,30 @@ async def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - async def get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + async def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -289,8 +290,10 @@ async def get_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.GetFeatureRequest(request) @@ -310,32 +313,26 @@ async def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Adds a new Feature. Args: @@ -381,8 +378,10 @@ async def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.CreateFeatureRequest(request) @@ -406,18 +405,11 @@ async def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -430,14 +422,15 @@ async def create_feature(self, # Done; return the response. return response - async def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Removes a Feature. Args: @@ -481,8 +474,10 @@ async def delete_feature(self, # 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.DeleteFeatureRequest(request) @@ -502,18 +497,11 @@ async def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -526,16 +514,17 @@ async def delete_feature(self, # Done; return the response. return response - async def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: + async def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: r"""Updates an existing Feature. Args: @@ -589,8 +578,10 @@ async def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.") + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) request = service.UpdateFeatureRequest(request) @@ -614,18 +605,11 @@ async def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -639,19 +623,12 @@ async def update_feature(self, return response - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubAsyncClient", -) +__all__ = ("GkeHubAsyncClient",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py b/google/cloud/gkehub_v1beta/services/gke_hub/client.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py rename to google/cloud/gkehub_v1beta/services/gke_hub/client.py index a7cf014..53b4adf 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/client.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/client.py @@ -21,14 +21,14 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # 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 from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -50,13 +50,12 @@ class GkeHubClientMeta(type): support objects (e.g. transport) without polluting the client instance objects. """ + _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] _transport_registry["grpc"] = GkeHubGrpcTransport _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - def get_transport_class(cls, - label: str = None, - ) -> Type[GkeHubTransport]: + def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: """Returns an appropriate transport class. Args: @@ -158,8 +157,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: GkeHubClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) + credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs) @@ -176,77 +174,88 @@ def transport(self) -> GkeHubTransport: return self._transport @staticmethod - def feature_path(project: str,location: str,feature: str,) -> str: + def feature_path(project: str, location: str, feature: str,) -> str: """Returns a fully-qualified feature string.""" - return "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + return "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) @staticmethod - def parse_feature_path(path: str) -> Dict[str,str]: + def parse_feature_path(path: str) -> Dict[str, str]: """Parses a feature path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/features/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: + def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: + def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P.+?)$", path) 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]: + def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P.+?)$", path) 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]: + def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P.+?)$", path) 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]: + def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P.+?)$", path) 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, ) + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: + def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, GkeHubTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the gke hub client. Args: @@ -290,7 +299,9 @@ def __init__(self, *, client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + use_client_cert = bool( + util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + ) client_cert_source_func = None is_mtls = False @@ -331,8 +342,10 @@ def __init__(self, *, if isinstance(transport, GkeHubTransport): # transport is a GkeHubTransport instance. if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) if client_options.scopes: raise ValueError( "When providing a transport instance, provide its scopes " @@ -351,14 +364,15 @@ def __init__(self, *, client_info=client_info, ) - def list_features(self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesPager: + def list_features( + self, + request: service.ListFeaturesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeaturesPager: r"""Lists Features in a given project and location. Args: @@ -392,8 +406,10 @@ def list_features(self, # 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.') + 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.ListFeaturesRequest. @@ -413,39 +429,30 @@ def list_features(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # 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.ListFeaturesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response - def get_feature(self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: + def get_feature( + self, + request: service.GetFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> feature.Feature: r"""Gets details of a single Feature. Args: @@ -476,8 +483,10 @@ def get_feature(self, # 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.') + 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.GetFeatureRequest. @@ -497,32 +506,26 @@ def get_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # 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 create_feature(self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def create_feature( + self, + request: service.CreateFeatureRequest = None, + *, + parent: str = None, + resource: feature.Feature = None, + feature_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Adds a new Feature. Args: @@ -568,8 +571,10 @@ def create_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, resource, feature_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.') + 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.CreateFeatureRequest. @@ -593,18 +598,11 @@ def create_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -617,14 +615,15 @@ def create_feature(self, # Done; return the response. return response - def delete_feature(self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def delete_feature( + self, + request: service.DeleteFeatureRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Removes a Feature. Args: @@ -668,8 +667,10 @@ def delete_feature(self, # 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.') + 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.DeleteFeatureRequest. @@ -689,18 +690,11 @@ def delete_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -713,16 +707,17 @@ def delete_feature(self, # Done; return the response. return response - def update_feature(self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: + def update_feature( + self, + request: service.UpdateFeatureRequest = None, + *, + name: str = None, + resource: feature.Feature = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: r"""Updates an existing Feature. Args: @@ -776,8 +771,10 @@ def update_feature(self, # gotten any keyword arguments that map to the request. has_flattened_params = any([name, resource, 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.') + 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.UpdateFeatureRequest. @@ -801,18 +798,11 @@ def update_feature(self, # 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), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = operation.from_gapic( @@ -826,19 +816,12 @@ def update_feature(self, return response - - - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "GkeHubClient", -) +__all__ = ("GkeHubClient",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py b/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py similarity index 86% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py rename to google/cloud/gkehub_v1beta/services/gke_hub/pagers.py index f86c6a1..39bf42c 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py @@ -13,7 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.gkehub_v1beta.types import feature from google.cloud.gkehub_v1beta.types import service @@ -36,12 +45,15 @@ class ListFeaturesPager: 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.ListFeaturesResponse], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., service.ListFeaturesResponse], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiate the pager. Args: @@ -75,7 +87,7 @@ def __iter__(self) -> Iterable[feature.Feature]: yield from page.resources def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListFeaturesAsyncPager: @@ -95,12 +107,15 @@ class ListFeaturesAsyncPager: 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.ListFeaturesResponse]], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[service.ListFeaturesResponse]], + request: service.ListFeaturesRequest, + response: service.ListFeaturesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): """Instantiates the pager. Args: @@ -138,4 +153,4 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py similarity index 82% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py rename to google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py index 29c1c45..50e3055 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py @@ -23,11 +23,11 @@ # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry['grpc'] = GkeHubGrpcTransport -_transport_registry['grpc_asyncio'] = GkeHubGrpcAsyncIOTransport +_transport_registry["grpc"] = GkeHubGrpcTransport +_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport __all__ = ( - 'GkeHubTransport', - 'GkeHubGrpcTransport', - 'GkeHubGrpcAsyncIOTransport', + "GkeHubTransport", + "GkeHubGrpcTransport", + "GkeHubGrpcAsyncIOTransport", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py similarity index 64% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py rename to google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py index fabd558..e3a8c15 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py @@ -21,11 +21,11 @@ import google.auth # type: ignore import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.gkehub_v1beta.types import feature from google.cloud.gkehub_v1beta.types import service @@ -33,9 +33,7 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-gke-hub', - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -53,22 +51,22 @@ class GkeHubTransport(abc.ABC): """Abstract transport class for GkeHub.""" - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + DEFAULT_HOST: str = "gkehub.googleapis.com" - DEFAULT_HOST: str = 'gkehub.googleapis.com' def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: """Instantiate the transport. Args: @@ -94,8 +92,8 @@ def __init__( be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' + if ":" not in host: + host += ":443" self._host = host scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) @@ -106,20 +104,26 @@ def __init__( # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. @@ -131,7 +135,9 @@ def __init__( # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" scopes_kwargs = {} @@ -150,31 +156,21 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_features: gapic_v1.method.wrap_method( - self.list_features, - default_timeout=None, - client_info=client_info, + self.list_features, default_timeout=None, client_info=client_info, ), self.get_feature: gapic_v1.method.wrap_method( - self.get_feature, - default_timeout=None, - client_info=client_info, + self.get_feature, default_timeout=None, client_info=client_info, ), self.create_feature: gapic_v1.method.wrap_method( - self.create_feature, - default_timeout=None, - client_info=client_info, + self.create_feature, default_timeout=None, client_info=client_info, ), self.delete_feature: gapic_v1.method.wrap_method( - self.delete_feature, - default_timeout=None, - client_info=client_info, + self.delete_feature, default_timeout=None, client_info=client_info, ), self.update_feature: gapic_v1.method.wrap_method( - self.update_feature, - default_timeout=None, - client_info=client_info, + self.update_feature, default_timeout=None, client_info=client_info, ), - } + } @property def operations_client(self) -> operations_v1.OperationsClient: @@ -182,51 +178,48 @@ def operations_client(self) -> operations_v1.OperationsClient: raise NotImplementedError() @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Union[ - service.ListFeaturesResponse, - Awaitable[service.ListFeaturesResponse] - ]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], + Union[service.ListFeaturesResponse, Awaitable[service.ListFeaturesResponse]], + ]: raise NotImplementedError() @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Union[ - feature.Feature, - Awaitable[feature.Feature] - ]]: + def get_feature( + self, + ) -> Callable[ + [service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]] + ]: raise NotImplementedError() @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def create_feature( + self, + ) -> Callable[ + [service.CreateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def delete_feature( + self, + ) -> Callable[ + [service.DeleteFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: + def update_feature( + self, + ) -> Callable[ + [service.UpdateFeatureRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: raise NotImplementedError() -__all__ = ( - 'GkeHubTransport', -) +__all__ = ("GkeHubTransport",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py rename to google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py index 7d0203a..d48007b 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py @@ -16,10 +16,10 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore +from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -56,21 +56,24 @@ class GkeHubGrpcTransport(GkeHubTransport): It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """ + _stubs: Dict[str, Callable] - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -184,13 +187,15 @@ def __init__(self, *, self._prep_wrapped_messages(client_info) @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. @@ -225,7 +230,7 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) @property @@ -243,17 +248,15 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Sanity check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. return self._operations_client @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - service.ListFeaturesResponse]: + def list_features( + self, + ) -> Callable[[service.ListFeaturesRequest], service.ListFeaturesResponse]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -268,18 +271,16 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - feature.Feature]: + def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -294,18 +295,18 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - operations_pb2.Operation]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -320,18 +321,18 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - operations_pb2.Operation]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -346,18 +347,18 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - operations_pb2.Operation]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], operations_pb2.Operation]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -372,15 +373,13 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] -__all__ = ( - 'GkeHubGrpcTransport', -) +__all__ = ("GkeHubGrpcTransport",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py similarity index 81% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py rename to google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py index d71e720..e1f8e03 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py @@ -16,14 +16,14 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import packaging.version -import grpc # type: ignore +import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.gkehub_v1beta.types import feature @@ -63,13 +63,15 @@ class GkeHubGrpcAsyncIOTransport(GkeHubTransport): _stubs: Dict[str, Callable] = {} @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: + def create_channel( + cls, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. @@ -100,22 +102,24 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + host: str = "gkehub.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiate the transport. Args: @@ -255,9 +259,11 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: return self._operations_client @property - def list_features(self) -> Callable[ - [service.ListFeaturesRequest], - Awaitable[service.ListFeaturesResponse]]: + def list_features( + self, + ) -> Callable[ + [service.ListFeaturesRequest], Awaitable[service.ListFeaturesResponse] + ]: r"""Return a callable for the list features method over gRPC. Lists Features in a given project and location. @@ -272,18 +278,18 @@ def list_features(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'list_features' not in self._stubs: - self._stubs['list_features'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/ListFeatures', + if "list_features" not in self._stubs: + self._stubs["list_features"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) - return self._stubs['list_features'] + return self._stubs["list_features"] @property - def get_feature(self) -> Callable[ - [service.GetFeatureRequest], - Awaitable[feature.Feature]]: + def get_feature( + self, + ) -> Callable[[service.GetFeatureRequest], Awaitable[feature.Feature]]: r"""Return a callable for the get feature method over gRPC. Gets details of a single Feature. @@ -298,18 +304,18 @@ def get_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'get_feature' not in self._stubs: - self._stubs['get_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/GetFeature', + if "get_feature" not in self._stubs: + self._stubs["get_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) - return self._stubs['get_feature'] + return self._stubs["get_feature"] @property - def create_feature(self) -> Callable[ - [service.CreateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def create_feature( + self, + ) -> Callable[[service.CreateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create feature method over gRPC. Adds a new Feature. @@ -324,18 +330,18 @@ def create_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'create_feature' not in self._stubs: - self._stubs['create_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/CreateFeature', + if "create_feature" not in self._stubs: + self._stubs["create_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['create_feature'] + return self._stubs["create_feature"] @property - def delete_feature(self) -> Callable[ - [service.DeleteFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def delete_feature( + self, + ) -> Callable[[service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete feature method over gRPC. Removes a Feature. @@ -350,18 +356,18 @@ def delete_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'delete_feature' not in self._stubs: - self._stubs['delete_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature', + if "delete_feature" not in self._stubs: + self._stubs["delete_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['delete_feature'] + return self._stubs["delete_feature"] @property - def update_feature(self) -> Callable[ - [service.UpdateFeatureRequest], - Awaitable[operations_pb2.Operation]]: + def update_feature( + self, + ) -> Callable[[service.UpdateFeatureRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update feature method over gRPC. Updates an existing Feature. @@ -376,15 +382,13 @@ def update_feature(self) -> Callable[ # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if 'update_feature' not in self._stubs: - self._stubs['update_feature'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature', + if "update_feature" not in self._stubs: + self._stubs["update_feature"] = self.grpc_channel.unary_unary( + "/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) - return self._stubs['update_feature'] + return self._stubs["update_feature"] -__all__ = ( - 'GkeHubGrpcAsyncIOTransport', -) +__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py b/google/cloud/gkehub_v1beta/types/__init__.py similarity index 73% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py rename to google/cloud/gkehub_v1beta/types/__init__.py index 09483e1..f966a52 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/__init__.py +++ b/google/cloud/gkehub_v1beta/types/__init__.py @@ -33,18 +33,18 @@ ) __all__ = ( - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'GetFeatureRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'OperationMetadata', - 'UpdateFeatureRequest', + "CommonFeatureSpec", + "CommonFeatureState", + "Feature", + "FeatureResourceState", + "FeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "GetFeatureRequest", + "ListFeaturesRequest", + "ListFeaturesResponse", + "OperationMetadata", + "UpdateFeatureRequest", ) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py b/google/cloud/gkehub_v1beta/types/feature.py similarity index 80% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py rename to google/cloud/gkehub_v1beta/types/feature.py index df6cb21..ea910f4 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/feature.py +++ b/google/cloud/gkehub_v1beta/types/feature.py @@ -22,15 +22,15 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1beta', + package="google.cloud.gkehub.v1beta", manifest={ - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', + "Feature", + "FeatureResourceState", + "FeatureState", + "CommonFeatureSpec", + "CommonFeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", }, ) @@ -98,56 +98,23 @@ class Feature(proto.Message): deleted. """ - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) resource_state = proto.Field( - proto.MESSAGE, - number=3, - message='FeatureResourceState', - ) - spec = proto.Field( - proto.MESSAGE, - number=4, - message='CommonFeatureSpec', + proto.MESSAGE, number=3, message="FeatureResourceState", ) + spec = proto.Field(proto.MESSAGE, number=4, message="CommonFeatureSpec",) membership_specs = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=5, - message='MembershipFeatureSpec', - ) - state = proto.Field( - proto.MESSAGE, - number=6, - message='CommonFeatureState', + proto.STRING, proto.MESSAGE, number=5, message="MembershipFeatureSpec", ) + state = proto.Field(proto.MESSAGE, number=6, message="CommonFeatureState",) membership_states = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=7, - message='MembershipFeatureState', - ) - create_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, + proto.STRING, proto.MESSAGE, number=7, message="MembershipFeatureState", ) + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) delete_time = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) @@ -161,6 +128,7 @@ class FeatureResourceState(proto.Message): The current state of the Feature resource in the Hub API. """ + class State(proto.Enum): r"""State describes the lifecycle status of a Feature.""" STATE_UNSPECIFIED = 0 @@ -170,11 +138,7 @@ class State(proto.Enum): UPDATING = 4 SERVICE_UPDATING = 5 - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) + state = proto.Field(proto.ENUM, number=1, enum=State,) class FeatureState(proto.Message): @@ -193,6 +157,7 @@ class FeatureState(proto.Message): The time this status and any related Feature- pecific details were updated. """ + class Code(proto.Enum): r"""Code represents a machine-readable, high-level status of the Feature. @@ -202,20 +167,9 @@ class Code(proto.Enum): WARNING = 2 ERROR = 3 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code,) + description = proto.Field(proto.STRING, number=2,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) class CommonFeatureSpec(proto.Message): @@ -228,7 +182,7 @@ class CommonFeatureSpec(proto.Message): multiclusteringress = proto.Field( proto.MESSAGE, number=102, - oneof='feature_spec', + oneof="feature_spec", message=multiclusteringress_pb2.FeatureSpec, ) @@ -243,11 +197,7 @@ class CommonFeatureState(proto.Message): Feature in this Hub. """ - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) class MembershipFeatureSpec(proto.Message): @@ -262,7 +212,7 @@ class MembershipFeatureSpec(proto.Message): configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_spec', + oneof="feature_spec", message=configmanagement_pb2.MembershipSpec, ) @@ -284,20 +234,16 @@ class MembershipFeatureState(proto.Message): metering = proto.Field( proto.MESSAGE, number=104, - oneof='feature_state', + oneof="feature_state", message=metering_pb2.MembershipState, ) configmanagement = proto.Field( proto.MESSAGE, number=106, - oneof='feature_state', + oneof="feature_state", message=configmanagement_pb2.MembershipState, ) - state = proto.Field( - proto.MESSAGE, - number=1, - message='FeatureState', - ) + state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py b/google/cloud/gkehub_v1beta/types/service.py similarity index 79% rename from owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py rename to google/cloud/gkehub_v1beta/types/service.py index 9b2bec9..cd21db8 100644 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/types/service.py +++ b/google/cloud/gkehub_v1beta/types/service.py @@ -21,15 +21,15 @@ __protobuf__ = proto.module( - package='google.cloud.gkehub.v1beta', + package="google.cloud.gkehub.v1beta", manifest={ - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'GetFeatureRequest', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'UpdateFeatureRequest', - 'OperationMetadata', + "ListFeaturesRequest", + "ListFeaturesResponse", + "GetFeatureRequest", + "CreateFeatureRequest", + "DeleteFeatureRequest", + "UpdateFeatureRequest", + "OperationMetadata", }, ) @@ -74,26 +74,11 @@ class ListFeaturesRequest(proto.Message): https://google.aip.dev/132#ordering. """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListFeaturesResponse(proto.Message): @@ -111,15 +96,8 @@ class ListFeaturesResponse(proto.Message): def raw_page(self): return self - resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=feature.Feature, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + resources = proto.RepeatedField(proto.MESSAGE, number=1, message=feature.Feature,) + next_page_token = proto.Field(proto.STRING, number=2,) class GetFeatureRequest(proto.Message): @@ -130,10 +108,7 @@ class GetFeatureRequest(proto.Message): ``projects/*/locations/*/features/*`` """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) class CreateFeatureRequest(proto.Message): @@ -166,23 +141,10 @@ class CreateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field( - proto.STRING, - number=1, - ) - feature_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1,) + feature_id = proto.Field(proto.STRING, number=2,) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class DeleteFeatureRequest(proto.Message): @@ -216,18 +178,9 @@ class DeleteFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) - force = proto.Field( - proto.BOOL, - number=2, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) + request_id = proto.Field(proto.STRING, number=3,) class UpdateFeatureRequest(proto.Message): @@ -267,24 +220,12 @@ class UpdateFeatureRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1,) update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message=feature.Feature, - ) - request_id = proto.Field( - proto.STRING, - number=4, + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) + resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) + request_id = proto.Field(proto.STRING, number=4,) class OperationMetadata(proto.Message): @@ -316,36 +257,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_detail = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_detail = proto.Field(proto.STRING, number=5,) + cancel_requested = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py b/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py index 97da42a..ae89f69 100644 --- a/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py +++ b/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py @@ -98,7 +98,7 @@ def __init__( scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc deleted file mode 100644 index 3cef77b..0000000 --- a/owl-bot-staging/v1/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/gkehub/multiclusteringress/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in deleted file mode 100644 index 6199da3..0000000 --- a/owl-bot-staging/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/gkehub/multiclusteringress *.py -recursive-include google/cloud/gkehub/multiclusteringress_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst deleted file mode 100644 index a4586cc..0000000 --- a/owl-bot-staging/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Gkehub Multiclusteringress API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Gkehub Multiclusteringress API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py deleted file mode 100644 index 03b3c7b..0000000 --- a/owl-bot-staging/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -# -# google-cloud-gkehub-multiclusteringress documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# 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 -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-gkehub-multiclusteringress" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Gkehub Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-gkehub-multiclusteringress-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress.tex", - u"google-cloud-gkehub-multiclusteringress Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress", - u"Google Cloud Gkehub Multiclusteringress Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress", - u"google-cloud-gkehub-multiclusteringress Documentation", - author, - "google-cloud-gkehub-multiclusteringress", - "GAPIC library for Google Cloud Gkehub Multiclusteringress API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1/docs/index.rst b/owl-bot-staging/v1/docs/index.rst deleted file mode 100644 index ad67e5b..0000000 --- a/owl-bot-staging/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - multiclusteringress_v1/services - multiclusteringress_v1/types diff --git a/owl-bot-staging/v1/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/__init__.py deleted file mode 100644 index db580ea..0000000 --- a/owl-bot-staging/v1/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1.services.gke_hub.client import GkeHubClient -from google.cloud.gkehub_v1.services.gke_hub.async_client import GkeHubAsyncClient - -from google.cloud.gkehub_v1.types.feature import CommonFeatureSpec -from google.cloud.gkehub_v1.types.feature import CommonFeatureState -from google.cloud.gkehub_v1.types.feature import Feature -from google.cloud.gkehub_v1.types.feature import FeatureResourceState -from google.cloud.gkehub_v1.types.feature import FeatureState -from google.cloud.gkehub_v1.types.feature import MembershipFeatureSpec -from google.cloud.gkehub_v1.types.feature import MembershipFeatureState -from google.cloud.gkehub_v1.types.membership import Authority -from google.cloud.gkehub_v1.types.membership import GkeCluster -from google.cloud.gkehub_v1.types.membership import KubernetesMetadata -from google.cloud.gkehub_v1.types.membership import Membership -from google.cloud.gkehub_v1.types.membership import MembershipEndpoint -from google.cloud.gkehub_v1.types.membership import MembershipState -from google.cloud.gkehub_v1.types.service import ConnectAgentResource -from google.cloud.gkehub_v1.types.service import CreateFeatureRequest -from google.cloud.gkehub_v1.types.service import CreateMembershipRequest -from google.cloud.gkehub_v1.types.service import DeleteFeatureRequest -from google.cloud.gkehub_v1.types.service import DeleteMembershipRequest -from google.cloud.gkehub_v1.types.service import GenerateConnectManifestRequest -from google.cloud.gkehub_v1.types.service import GenerateConnectManifestResponse -from google.cloud.gkehub_v1.types.service import GetFeatureRequest -from google.cloud.gkehub_v1.types.service import GetMembershipRequest -from google.cloud.gkehub_v1.types.service import ListFeaturesRequest -from google.cloud.gkehub_v1.types.service import ListFeaturesResponse -from google.cloud.gkehub_v1.types.service import ListMembershipsRequest -from google.cloud.gkehub_v1.types.service import ListMembershipsResponse -from google.cloud.gkehub_v1.types.service import OperationMetadata -from google.cloud.gkehub_v1.types.service import TypeMeta -from google.cloud.gkehub_v1.types.service import UpdateFeatureRequest -from google.cloud.gkehub_v1.types.service import UpdateMembershipRequest - -__all__ = ('GkeHubClient', - 'GkeHubAsyncClient', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'Authority', - 'GkeCluster', - 'KubernetesMetadata', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'ConnectAgentResource', - 'CreateFeatureRequest', - 'CreateMembershipRequest', - 'DeleteFeatureRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GetFeatureRequest', - 'GetMembershipRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'OperationMetadata', - 'TypeMeta', - 'UpdateFeatureRequest', - 'UpdateMembershipRequest', -) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py deleted file mode 100644 index a3176a9..0000000 --- a/owl-bot-staging/v1/google/cloud/gkehub/configmanagement/__init__.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSync -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncDeploymentState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSyncVersion -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ErrorResource -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GatekeeperDeploymentState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GitConfig -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GroupVersionKind -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerConfig -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerDeploymentState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import HierarchyControllerVersion -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import InstallError -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import MembershipSpec -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import MembershipState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import OperatorState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyController -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyControllerState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import PolicyControllerVersion -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncError -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncState -from google.cloud.gkehub.configmanagement_v1.types.configmanagement import DeploymentState - -__all__ = ('ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', -) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py deleted file mode 100644 index 2cf0ef2..0000000 --- a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.multiclusteringress_v1.types.multiclusteringress import FeatureSpec - -__all__ = ('FeatureSpec', -) diff --git a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py deleted file mode 100644 index 03f4faa..0000000 --- a/owl-bot-staging/v1/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .multiclusteringress import ( - FeatureSpec, -) - -__all__ = ( - 'FeatureSpec', -) diff --git a/owl-bot-staging/v1/mypy.ini b/owl-bot-staging/v1/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1/noxfile.py b/owl-bot-staging/v1/noxfile.py deleted file mode 100644 index 7a7b5ac..0000000 --- a/owl-bot-staging/v1/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/gkehub/multiclusteringress_v1/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1/setup.py b/owl-bot-staging/v1/setup.py deleted file mode 100644 index e2e8ad3..0000000 --- a/owl-bot-staging/v1/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-gkehub-multiclusteringress', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/multiclusteringress_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/.coveragerc b/owl-bot-staging/v1alpha/.coveragerc deleted file mode 100644 index deeba63..0000000 --- a/owl-bot-staging/v1alpha/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/gkehub/servicemesh/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1alpha/MANIFEST.in b/owl-bot-staging/v1alpha/MANIFEST.in deleted file mode 100644 index ae7c3f3..0000000 --- a/owl-bot-staging/v1alpha/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/gkehub/servicemesh *.py -recursive-include google/cloud/gkehub/servicemesh_v1alpha *.py diff --git a/owl-bot-staging/v1alpha/README.rst b/owl-bot-staging/v1alpha/README.rst deleted file mode 100644 index db8da88..0000000 --- a/owl-bot-staging/v1alpha/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Gkehub Servicemesh API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Gkehub Servicemesh API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1alpha/docs/conf.py b/owl-bot-staging/v1alpha/docs/conf.py deleted file mode 100644 index cd62351..0000000 --- a/owl-bot-staging/v1alpha/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -# -# google-cloud-gkehub-servicemesh documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# 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 -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-gkehub-servicemesh" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Gkehub Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-gkehub-servicemesh-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-gkehub-servicemesh.tex", - u"google-cloud-gkehub-servicemesh Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-gkehub-servicemesh", - u"Google Cloud Gkehub Servicemesh Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-gkehub-servicemesh", - u"google-cloud-gkehub-servicemesh Documentation", - author, - "google-cloud-gkehub-servicemesh", - "GAPIC library for Google Cloud Gkehub Servicemesh API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1alpha/docs/index.rst b/owl-bot-staging/v1alpha/docs/index.rst deleted file mode 100644 index fb0e098..0000000 --- a/owl-bot-staging/v1alpha/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - servicemesh_v1alpha/services - servicemesh_v1alpha/types diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py deleted file mode 100644 index 320d3fa..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1alpha.services.gke_hub.client import GkeHubClient -from google.cloud.gkehub_v1alpha.services.gke_hub.async_client import GkeHubAsyncClient - -from google.cloud.gkehub_v1alpha.types.feature import CommonFeatureSpec -from google.cloud.gkehub_v1alpha.types.feature import CommonFeatureState -from google.cloud.gkehub_v1alpha.types.feature import Feature -from google.cloud.gkehub_v1alpha.types.feature import FeatureResourceState -from google.cloud.gkehub_v1alpha.types.feature import FeatureState -from google.cloud.gkehub_v1alpha.types.feature import MembershipFeatureSpec -from google.cloud.gkehub_v1alpha.types.feature import MembershipFeatureState -from google.cloud.gkehub_v1alpha.types.service import CreateFeatureRequest -from google.cloud.gkehub_v1alpha.types.service import DeleteFeatureRequest -from google.cloud.gkehub_v1alpha.types.service import GetFeatureRequest -from google.cloud.gkehub_v1alpha.types.service import ListFeaturesRequest -from google.cloud.gkehub_v1alpha.types.service import ListFeaturesResponse -from google.cloud.gkehub_v1alpha.types.service import OperationMetadata -from google.cloud.gkehub_v1alpha.types.service import UpdateFeatureRequest - -__all__ = ('GkeHubClient', - 'GkeHubAsyncClient', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'GetFeatureRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'OperationMetadata', - 'UpdateFeatureRequest', -) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py deleted file mode 100644 index d2b5688..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .cloudauditlogging import ( - FeatureSpec, -) - -__all__ = ( - 'FeatureSpec', -) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py deleted file mode 100644 index 3df965d..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/configmanagement/__init__.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzConfig -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import BinauthzVersion -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSync -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncDeploymentState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ConfigSyncVersion -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import ErrorResource -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GatekeeperDeploymentState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GitConfig -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import GroupVersionKind -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerConfig -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerDeploymentState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import HierarchyControllerVersion -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import InstallError -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import MembershipSpec -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import MembershipState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import OperatorState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyController -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyControllerState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import PolicyControllerVersion -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import SyncError -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import SyncState -from google.cloud.gkehub.configmanagement_v1alpha.types.configmanagement import DeploymentState - -__all__ = ('BinauthzConfig', - 'BinauthzState', - 'BinauthzVersion', - 'ConfigSync', - 'ConfigSyncDeploymentState', - 'ConfigSyncState', - 'ConfigSyncVersion', - 'ErrorResource', - 'GatekeeperDeploymentState', - 'GitConfig', - 'GroupVersionKind', - 'HierarchyControllerConfig', - 'HierarchyControllerDeploymentState', - 'HierarchyControllerState', - 'HierarchyControllerVersion', - 'InstallError', - 'MembershipSpec', - 'MembershipState', - 'OperatorState', - 'PolicyController', - 'PolicyControllerState', - 'PolicyControllerVersion', - 'SyncError', - 'SyncState', - 'DeploymentState', -) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py deleted file mode 100644 index d22f218..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.metering_v1alpha.types.metering import MembershipState - -__all__ = ('MembershipState', -) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py deleted file mode 100644 index 9a626f7..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/metering_v1alpha/types/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .metering import ( - MembershipState, -) - -__all__ = ( - 'MembershipState', -) diff --git a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py b/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py deleted file mode 100644 index 6881b60..0000000 --- a/owl-bot-staging/v1alpha/google/cloud/gkehub/multiclusteringress/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.multiclusteringress_v1alpha.types.multiclusteringress import FeatureSpec -from google.cloud.gkehub.multiclusteringress_v1alpha.types.multiclusteringress import Billing - -__all__ = ('FeatureSpec', - 'Billing', -) diff --git a/owl-bot-staging/v1alpha/mypy.ini b/owl-bot-staging/v1alpha/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1alpha/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1alpha/noxfile.py b/owl-bot-staging/v1alpha/noxfile.py deleted file mode 100644 index 17622d4..0000000 --- a/owl-bot-staging/v1alpha/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/gkehub/servicemesh_v1alpha/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1alpha/setup.py b/owl-bot-staging/v1alpha/setup.py deleted file mode 100644 index f9b3488..0000000 --- a/owl-bot-staging/v1alpha/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-gkehub-servicemesh', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1alpha/tests/__init__.py b/owl-bot-staging/v1alpha/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/__init__.py b/owl-bot-staging/v1alpha/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/configmanagement_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/metering_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/servicemesh_v1alpha/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha2/.coveragerc b/owl-bot-staging/v1alpha2/.coveragerc deleted file mode 100644 index 2b3ad0f..0000000 --- a/owl-bot-staging/v1alpha2/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/gkehub/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1alpha2/MANIFEST.in b/owl-bot-staging/v1alpha2/MANIFEST.in deleted file mode 100644 index 794cce1..0000000 --- a/owl-bot-staging/v1alpha2/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/gkehub *.py -recursive-include google/cloud/gkehub_v1alpha2 *.py diff --git a/owl-bot-staging/v1alpha2/README.rst b/owl-bot-staging/v1alpha2/README.rst deleted file mode 100644 index 00b883a..0000000 --- a/owl-bot-staging/v1alpha2/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Gkehub API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Gkehub API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1alpha2/docs/conf.py b/owl-bot-staging/v1alpha2/docs/conf.py deleted file mode 100644 index 2e842ec..0000000 --- a/owl-bot-staging/v1alpha2/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -# -# google-cloud-gke-hub documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# 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 -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-gke-hub" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-gke-hub-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-gke-hub.tex", - u"google-cloud-gke-hub Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-gke-hub", - u"Google Cloud Gkehub Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-gke-hub", - u"google-cloud-gke-hub Documentation", - author, - "google-cloud-gke-hub", - "GAPIC library for Google Cloud Gkehub API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1alpha2/docs/index.rst b/owl-bot-staging/v1alpha2/docs/index.rst deleted file mode 100644 index c95b286..0000000 --- a/owl-bot-staging/v1alpha2/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - gkehub_v1alpha2/services - gkehub_v1alpha2/types diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py deleted file mode 100644 index 2a00e9b..0000000 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1alpha2.services.gke_hub.client import GkeHubClient -from google.cloud.gkehub_v1alpha2.services.gke_hub.async_client import GkeHubAsyncClient - -from google.cloud.gkehub_v1alpha2.types.membership import Authority -from google.cloud.gkehub_v1alpha2.types.membership import ConnectAgentResource -from google.cloud.gkehub_v1alpha2.types.membership import CreateMembershipRequest -from google.cloud.gkehub_v1alpha2.types.membership import DeleteMembershipRequest -from google.cloud.gkehub_v1alpha2.types.membership import GenerateConnectManifestRequest -from google.cloud.gkehub_v1alpha2.types.membership import GenerateConnectManifestResponse -from google.cloud.gkehub_v1alpha2.types.membership import GetMembershipRequest -from google.cloud.gkehub_v1alpha2.types.membership import GkeCluster -from google.cloud.gkehub_v1alpha2.types.membership import InitializeHubRequest -from google.cloud.gkehub_v1alpha2.types.membership import InitializeHubResponse -from google.cloud.gkehub_v1alpha2.types.membership import KubernetesMetadata -from google.cloud.gkehub_v1alpha2.types.membership import KubernetesResource -from google.cloud.gkehub_v1alpha2.types.membership import ListMembershipsRequest -from google.cloud.gkehub_v1alpha2.types.membership import ListMembershipsResponse -from google.cloud.gkehub_v1alpha2.types.membership import Membership -from google.cloud.gkehub_v1alpha2.types.membership import MembershipEndpoint -from google.cloud.gkehub_v1alpha2.types.membership import MembershipState -from google.cloud.gkehub_v1alpha2.types.membership import OperationMetadata -from google.cloud.gkehub_v1alpha2.types.membership import ResourceManifest -from google.cloud.gkehub_v1alpha2.types.membership import ResourceOptions -from google.cloud.gkehub_v1alpha2.types.membership import TypeMeta -from google.cloud.gkehub_v1alpha2.types.membership import UpdateMembershipRequest - -__all__ = ('GkeHubClient', - 'GkeHubAsyncClient', - 'Authority', - 'ConnectAgentResource', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GetMembershipRequest', - 'GkeCluster', - 'InitializeHubRequest', - 'InitializeHubResponse', - 'KubernetesMetadata', - 'KubernetesResource', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'OperationMetadata', - 'ResourceManifest', - 'ResourceOptions', - 'TypeMeta', - 'UpdateMembershipRequest', -) diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed b/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed b/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1alpha2/google/cloud/gkehub_v1alpha2/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1alpha2/mypy.ini b/owl-bot-staging/v1alpha2/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1alpha2/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1alpha2/noxfile.py b/owl-bot-staging/v1alpha2/noxfile.py deleted file mode 100644 index 60daabe..0000000 --- a/owl-bot-staging/v1alpha2/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/gkehub_v1alpha2/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1alpha2/setup.py b/owl-bot-staging/v1alpha2/setup.py deleted file mode 100644 index 2c5fa00..0000000 --- a/owl-bot-staging/v1alpha2/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-gke-hub', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1alpha2/tests/__init__.py b/owl-bot-staging/v1alpha2/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha2/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha2/tests/unit/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha2/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha2/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py b/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/.coveragerc b/owl-bot-staging/v1beta/.coveragerc deleted file mode 100644 index 3cef77b..0000000 --- a/owl-bot-staging/v1beta/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/gkehub/multiclusteringress/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1beta/MANIFEST.in b/owl-bot-staging/v1beta/MANIFEST.in deleted file mode 100644 index c6cdb90..0000000 --- a/owl-bot-staging/v1beta/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/gkehub/multiclusteringress *.py -recursive-include google/cloud/gkehub/multiclusteringress_v1beta *.py diff --git a/owl-bot-staging/v1beta/README.rst b/owl-bot-staging/v1beta/README.rst deleted file mode 100644 index a4586cc..0000000 --- a/owl-bot-staging/v1beta/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Gkehub Multiclusteringress API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Gkehub Multiclusteringress API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta/docs/conf.py b/owl-bot-staging/v1beta/docs/conf.py deleted file mode 100644 index 03b3c7b..0000000 --- a/owl-bot-staging/v1beta/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -# -# google-cloud-gkehub-multiclusteringress documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# 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 -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-gkehub-multiclusteringress" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Gkehub Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-gkehub-multiclusteringress-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress.tex", - u"google-cloud-gkehub-multiclusteringress Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress", - u"Google Cloud Gkehub Multiclusteringress Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-gkehub-multiclusteringress", - u"google-cloud-gkehub-multiclusteringress Documentation", - author, - "google-cloud-gkehub-multiclusteringress", - "GAPIC library for Google Cloud Gkehub Multiclusteringress API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta/docs/index.rst b/owl-bot-staging/v1beta/docs/index.rst deleted file mode 100644 index 814ab4a..0000000 --- a/owl-bot-staging/v1beta/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - multiclusteringress_v1beta/services - multiclusteringress_v1beta/types diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py deleted file mode 100644 index 04391d2..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1beta.services.gke_hub.client import GkeHubClient -from google.cloud.gkehub_v1beta.services.gke_hub.async_client import GkeHubAsyncClient - -from google.cloud.gkehub_v1beta.types.feature import CommonFeatureSpec -from google.cloud.gkehub_v1beta.types.feature import CommonFeatureState -from google.cloud.gkehub_v1beta.types.feature import Feature -from google.cloud.gkehub_v1beta.types.feature import FeatureResourceState -from google.cloud.gkehub_v1beta.types.feature import FeatureState -from google.cloud.gkehub_v1beta.types.feature import MembershipFeatureSpec -from google.cloud.gkehub_v1beta.types.feature import MembershipFeatureState -from google.cloud.gkehub_v1beta.types.service import CreateFeatureRequest -from google.cloud.gkehub_v1beta.types.service import DeleteFeatureRequest -from google.cloud.gkehub_v1beta.types.service import GetFeatureRequest -from google.cloud.gkehub_v1beta.types.service import ListFeaturesRequest -from google.cloud.gkehub_v1beta.types.service import ListFeaturesResponse -from google.cloud.gkehub_v1beta.types.service import OperationMetadata -from google.cloud.gkehub_v1beta.types.service import UpdateFeatureRequest - -__all__ = ('GkeHubClient', - 'GkeHubAsyncClient', - 'CommonFeatureSpec', - 'CommonFeatureState', - 'Feature', - 'FeatureResourceState', - 'FeatureState', - 'MembershipFeatureSpec', - 'MembershipFeatureState', - 'CreateFeatureRequest', - 'DeleteFeatureRequest', - 'GetFeatureRequest', - 'ListFeaturesRequest', - 'ListFeaturesResponse', - 'OperationMetadata', - 'UpdateFeatureRequest', -) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed deleted file mode 100644 index 5d21684..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed deleted file mode 100644 index 5d21684..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/configmanagement_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed deleted file mode 100644 index 1947b3f..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-metering package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py b/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py deleted file mode 100644 index 9a626f7..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/metering_v1beta/types/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .metering import ( - MembershipState, -) - -__all__ = ( - 'MembershipState', -) diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed deleted file mode 100644 index 298daf2..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed deleted file mode 100644 index 298daf2..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/multiclusteringress_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed b/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1beta/google/cloud/gkehub_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta/mypy.ini b/owl-bot-staging/v1beta/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1beta/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1beta/noxfile.py b/owl-bot-staging/v1beta/noxfile.py deleted file mode 100644 index 7bcadea..0000000 --- a/owl-bot-staging/v1beta/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/gkehub/multiclusteringress_v1beta/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1beta/setup.py b/owl-bot-staging/v1beta/setup.py deleted file mode 100644 index e2e8ad3..0000000 --- a/owl-bot-staging/v1beta/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-gkehub-multiclusteringress', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud', 'google.cloud.gkehub'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1beta/tests/__init__.py b/owl-bot-staging/v1beta/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/__init__.py b/owl-bot-staging/v1beta/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/gapic/configmanagement_v1beta/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/gapic/metering_v1beta/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py b/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta/tests/unit/gapic/multiclusteringress_v1beta/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta1/.coveragerc b/owl-bot-staging/v1beta1/.coveragerc deleted file mode 100644 index 2b3ad0f..0000000 --- a/owl-bot-staging/v1beta1/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/gkehub/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1beta1/MANIFEST.in b/owl-bot-staging/v1beta1/MANIFEST.in deleted file mode 100644 index 5a63cc9..0000000 --- a/owl-bot-staging/v1beta1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/gkehub *.py -recursive-include google/cloud/gkehub_v1beta1 *.py diff --git a/owl-bot-staging/v1beta1/README.rst b/owl-bot-staging/v1beta1/README.rst deleted file mode 100644 index 00b883a..0000000 --- a/owl-bot-staging/v1beta1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Gkehub API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Gkehub API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta1/docs/conf.py b/owl-bot-staging/v1beta1/docs/conf.py deleted file mode 100644 index 2e842ec..0000000 --- a/owl-bot-staging/v1beta1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -# -# google-cloud-gke-hub documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# 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 -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-gke-hub" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-gke-hub-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-gke-hub.tex", - u"google-cloud-gke-hub Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-gke-hub", - u"Google Cloud Gkehub Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-gke-hub", - u"google-cloud-gke-hub Documentation", - author, - "google-cloud-gke-hub", - "GAPIC library for Google Cloud Gkehub API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst deleted file mode 100644 index d234533..0000000 --- a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/gke_hub_membership_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -GkeHubMembershipService ------------------------------------------ - -.. automodule:: google.cloud.gkehub_v1beta1.services.gke_hub_membership_service - :members: - :inherited-members: - -.. automodule:: google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst deleted file mode 100644 index 5ebd7a6..0000000 --- a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Gkehub v1beta1 API -============================================ -.. toctree:: - :maxdepth: 2 - - gke_hub_membership_service diff --git a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst b/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst deleted file mode 100644 index 1f1cb49..0000000 --- a/owl-bot-staging/v1beta1/docs/gkehub_v1beta1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub v1beta1 API -========================================= - -.. automodule:: google.cloud.gkehub_v1beta1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1beta1/docs/index.rst b/owl-bot-staging/v1beta1/docs/index.rst deleted file mode 100644 index c840d89..0000000 --- a/owl-bot-staging/v1beta1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - gkehub_v1beta1/services - gkehub_v1beta1/types diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py deleted file mode 100644 index 8c1271f..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.client import GkeHubMembershipServiceClient -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.async_client import GkeHubMembershipServiceAsyncClient - -from google.cloud.gkehub_v1beta1.types.membership import Authority -from google.cloud.gkehub_v1beta1.types.membership import ConnectAgent -from google.cloud.gkehub_v1beta1.types.membership import ConnectAgentResource -from google.cloud.gkehub_v1beta1.types.membership import CreateMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import DeleteMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestRequest -from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestResponse -from google.cloud.gkehub_v1beta1.types.membership import GenerateExclusivityManifestRequest -from google.cloud.gkehub_v1beta1.types.membership import GenerateExclusivityManifestResponse -from google.cloud.gkehub_v1beta1.types.membership import GetMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import GkeCluster -from google.cloud.gkehub_v1beta1.types.membership import KubernetesMetadata -from google.cloud.gkehub_v1beta1.types.membership import KubernetesResource -from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsRequest -from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsResponse -from google.cloud.gkehub_v1beta1.types.membership import Membership -from google.cloud.gkehub_v1beta1.types.membership import MembershipEndpoint -from google.cloud.gkehub_v1beta1.types.membership import MembershipState -from google.cloud.gkehub_v1beta1.types.membership import OperationMetadata -from google.cloud.gkehub_v1beta1.types.membership import ResourceManifest -from google.cloud.gkehub_v1beta1.types.membership import ResourceOptions -from google.cloud.gkehub_v1beta1.types.membership import TypeMeta -from google.cloud.gkehub_v1beta1.types.membership import UpdateMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityRequest -from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityResponse - -__all__ = ('GkeHubMembershipServiceClient', - 'GkeHubMembershipServiceAsyncClient', - 'Authority', - 'ConnectAgent', - 'ConnectAgentResource', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GenerateExclusivityManifestRequest', - 'GenerateExclusivityManifestResponse', - 'GetMembershipRequest', - 'GkeCluster', - 'KubernetesMetadata', - 'KubernetesResource', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'OperationMetadata', - 'ResourceManifest', - 'ResourceOptions', - 'TypeMeta', - 'UpdateMembershipRequest', - 'ValidateExclusivityRequest', - 'ValidateExclusivityResponse', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed b/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py deleted file mode 100644 index 056d84e..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/__init__.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .services.gke_hub_membership_service import GkeHubMembershipServiceClient -from .services.gke_hub_membership_service import GkeHubMembershipServiceAsyncClient - -from .types.membership import Authority -from .types.membership import ConnectAgent -from .types.membership import ConnectAgentResource -from .types.membership import CreateMembershipRequest -from .types.membership import DeleteMembershipRequest -from .types.membership import GenerateConnectManifestRequest -from .types.membership import GenerateConnectManifestResponse -from .types.membership import GenerateExclusivityManifestRequest -from .types.membership import GenerateExclusivityManifestResponse -from .types.membership import GetMembershipRequest -from .types.membership import GkeCluster -from .types.membership import KubernetesMetadata -from .types.membership import KubernetesResource -from .types.membership import ListMembershipsRequest -from .types.membership import ListMembershipsResponse -from .types.membership import Membership -from .types.membership import MembershipEndpoint -from .types.membership import MembershipState -from .types.membership import OperationMetadata -from .types.membership import ResourceManifest -from .types.membership import ResourceOptions -from .types.membership import TypeMeta -from .types.membership import UpdateMembershipRequest -from .types.membership import ValidateExclusivityRequest -from .types.membership import ValidateExclusivityResponse - -__all__ = ( - 'GkeHubMembershipServiceAsyncClient', -'Authority', -'ConnectAgent', -'ConnectAgentResource', -'CreateMembershipRequest', -'DeleteMembershipRequest', -'GenerateConnectManifestRequest', -'GenerateConnectManifestResponse', -'GenerateExclusivityManifestRequest', -'GenerateExclusivityManifestResponse', -'GetMembershipRequest', -'GkeCluster', -'GkeHubMembershipServiceClient', -'KubernetesMetadata', -'KubernetesResource', -'ListMembershipsRequest', -'ListMembershipsResponse', -'Membership', -'MembershipEndpoint', -'MembershipState', -'OperationMetadata', -'ResourceManifest', -'ResourceOptions', -'TypeMeta', -'UpdateMembershipRequest', -'ValidateExclusivityRequest', -'ValidateExclusivityResponse', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json deleted file mode 100644 index 9f0aee4..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/gapic_metadata.json +++ /dev/null @@ -1,103 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub_v1beta1", - "protoPackage": "google.cloud.gkehub.v1beta1", - "schema": "1.0", - "services": { - "GkeHubMembershipService": { - "clients": { - "grpc": { - "libraryClient": "GkeHubMembershipServiceClient", - "rpcs": { - "CreateMembership": { - "methods": [ - "create_membership" - ] - }, - "DeleteMembership": { - "methods": [ - "delete_membership" - ] - }, - "GenerateConnectManifest": { - "methods": [ - "generate_connect_manifest" - ] - }, - "GenerateExclusivityManifest": { - "methods": [ - "generate_exclusivity_manifest" - ] - }, - "GetMembership": { - "methods": [ - "get_membership" - ] - }, - "ListMemberships": { - "methods": [ - "list_memberships" - ] - }, - "UpdateMembership": { - "methods": [ - "update_membership" - ] - }, - "ValidateExclusivity": { - "methods": [ - "validate_exclusivity" - ] - } - } - }, - "grpc-async": { - "libraryClient": "GkeHubMembershipServiceAsyncClient", - "rpcs": { - "CreateMembership": { - "methods": [ - "create_membership" - ] - }, - "DeleteMembership": { - "methods": [ - "delete_membership" - ] - }, - "GenerateConnectManifest": { - "methods": [ - "generate_connect_manifest" - ] - }, - "GenerateExclusivityManifest": { - "methods": [ - "generate_exclusivity_manifest" - ] - }, - "GetMembership": { - "methods": [ - "get_membership" - ] - }, - "ListMemberships": { - "methods": [ - "list_memberships" - ] - }, - "UpdateMembership": { - "methods": [ - "update_membership" - ] - }, - "ValidateExclusivity": { - "methods": [ - "validate_exclusivity" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py deleted file mode 100644 index 4b66850..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .client import GkeHubMembershipServiceClient -from .async_client import GkeHubMembershipServiceAsyncClient - -__all__ = ( - 'GkeHubMembershipServiceClient', - 'GkeHubMembershipServiceAsyncClient', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py deleted file mode 100644 index 689b04c..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/async_client.py +++ /dev/null @@ -1,842 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers -from google.cloud.gkehub_v1beta1.types import membership -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore -from .transports.base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport -from .client import GkeHubMembershipServiceClient - - -class GkeHubMembershipServiceAsyncClient: - """GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - """ - - _client: GkeHubMembershipServiceClient - - DEFAULT_ENDPOINT = GkeHubMembershipServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = GkeHubMembershipServiceClient.DEFAULT_MTLS_ENDPOINT - - membership_path = staticmethod(GkeHubMembershipServiceClient.membership_path) - parse_membership_path = staticmethod(GkeHubMembershipServiceClient.parse_membership_path) - common_billing_account_path = staticmethod(GkeHubMembershipServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(GkeHubMembershipServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(GkeHubMembershipServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(GkeHubMembershipServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(GkeHubMembershipServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(GkeHubMembershipServiceClient.parse_common_organization_path) - common_project_path = staticmethod(GkeHubMembershipServiceClient.common_project_path) - parse_common_project_path = staticmethod(GkeHubMembershipServiceClient.parse_common_project_path) - common_location_path = staticmethod(GkeHubMembershipServiceClient.common_location_path) - parse_common_location_path = staticmethod(GkeHubMembershipServiceClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubMembershipServiceAsyncClient: The constructed client. - """ - return GkeHubMembershipServiceClient.from_service_account_info.__func__(GkeHubMembershipServiceAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubMembershipServiceAsyncClient: The constructed client. - """ - return GkeHubMembershipServiceClient.from_service_account_file.__func__(GkeHubMembershipServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubMembershipServiceTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubMembershipServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(GkeHubMembershipServiceClient).get_transport_class, type(GkeHubMembershipServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubMembershipServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub membership service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.GkeHubMembershipServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = GkeHubMembershipServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_memberships(self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsAsyncPager: - r"""Lists Memberships in a given project and location. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.ListMembershipsRequest`): - The request object. Request message for - `GkeHubMembershipService.ListMemberships` method. - parent (:class:`str`): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/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.gkehub_v1beta1.services.gke_hub_membership_service.pagers.ListMembershipsAsyncPager: - Response message for the - GkeHubMembershipService.ListMemberships method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 = membership.ListMembershipsRequest(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_memberships, - 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.ListMembershipsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_membership(self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: - r"""Gets the details of a Membership. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.GetMembershipRequest`): - The request object. Request message for - `GkeHubMembershipService.GetMembership` method. - name (:class:`str`): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - 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.gkehub_v1beta1.types.Membership: - Membership contains information about - a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = membership.GetMembershipRequest(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_membership, - 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 create_membership(self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Adds a new Membership. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.CreateMembershipRequest`): - The request object. Request message for the - `GkeHubMembershipService.CreateMembership` method. - parent (:class:`str`): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1beta1.types.Membership`): - Required. The membership to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - membership_id (:class:`str`): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters - or ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length - of 63 characters. - - This corresponds to the ``membership_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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta1.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, membership_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 = membership.CreateMembershipRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if membership_id is not None: - request.membership_id = membership_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_membership, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_membership(self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Removes a Membership. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.DeleteMembershipRequest`): - The request object. Request message for - `GkeHubMembershipService.DeleteMembership` method. - name (:class:`str`): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = membership.DeleteMembershipRequest(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_membership, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_membership(self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates an existing Membership. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.UpdateMembershipRequest`): - The request object. Request message for - `GkeHubMembershipService.UpdateMembership` method. - name (:class:`str`): - Required. The membership resource name in the format: - ``projects/[project_id]/locations/global/memberships/[membership_id]`` - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1beta1.types.Membership`): - Required. Only fields specified in update_mask are - updated. If you specify a field in the update_mask but - don't specify its value here that field will be deleted. - If you are updating a map field, set the value of a key - to null or empty string to delete the key from the map. - It's not possible to update a key's value to the empty - string. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Mask of fields to update. - At least one field path must be - specified in this mask. - - 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta1.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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 = membership.UpdateMembershipRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_membership, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def generate_connect_manifest(self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: - r"""Generates the manifest for deployment of the GKE - connect agent. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.GenerateConnectManifestRequest`): - The request object. Request message for - `GkeHubMembershipService.GenerateConnectManifest` - method. . - 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.gkehub_v1beta1.types.GenerateConnectManifestResponse: - GenerateConnectManifestResponse - contains manifest information for - installing/upgrading a Connect agent. - - """ - # Create or coerce a protobuf request object. - request = membership.GenerateConnectManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.generate_connect_manifest, - 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 validate_exclusivity(self, - request: membership.ValidateExclusivityRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.ValidateExclusivityResponse: - r"""ValidateExclusivity validates the state of - exclusivity in the cluster. The validation does not - depend on an existing Hub membership resource. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.ValidateExclusivityRequest`): - The request object. The request to validate the existing - state of the membership CR in the cluster. - 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.gkehub_v1beta1.types.ValidateExclusivityResponse: - The response of exclusivity artifacts - validation result status. - - """ - # Create or coerce a protobuf request object. - request = membership.ValidateExclusivityRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.validate_exclusivity, - 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 generate_exclusivity_manifest(self, - request: membership.GenerateExclusivityManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateExclusivityManifestResponse: - r"""GenerateExclusivityManifest generates the manifests - to update the exclusivity artifacts in the cluster if - needed. - Exclusivity artifacts include the Membership custom - resource definition (CRD) and the singleton Membership - custom resource (CR). Combined with ValidateExclusivity, - exclusivity artifacts guarantee that a Kubernetes - cluster is only registered to a single GKE Hub. - - The Membership CRD is versioned, and may require - conversion when the GKE Hub API server begins serving a - newer version of the CRD and corresponding CR. The - response will be the converted CRD and CR if there are - any differences between the versions. - - Args: - request (:class:`google.cloud.gkehub_v1beta1.types.GenerateExclusivityManifestRequest`): - The request object. The request to generate the - manifests for exclusivity artifacts. - 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.gkehub_v1beta1.types.GenerateExclusivityManifestResponse: - The response of the exclusivity - artifacts manifests for the client to - apply. - - """ - # Create or coerce a protobuf request object. - request = membership.GenerateExclusivityManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.generate_exclusivity_manifest, - 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 - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "GkeHubMembershipServiceAsyncClient", -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py deleted file mode 100644 index 2bd7ce0..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/client.py +++ /dev/null @@ -1,1032 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers -from google.cloud.gkehub_v1beta1.types import membership -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore -from .transports.base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import GkeHubMembershipServiceGrpcTransport -from .transports.grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport - - -class GkeHubMembershipServiceClientMeta(type): - """Metaclass for the GkeHubMembershipService client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubMembershipServiceTransport]] - _transport_registry["grpc"] = GkeHubMembershipServiceGrpcTransport - _transport_registry["grpc_asyncio"] = GkeHubMembershipServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[GkeHubMembershipServiceTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class GkeHubMembershipServiceClient(metaclass=GkeHubMembershipServiceClientMeta): - """GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "gkehub.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubMembershipServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubMembershipServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubMembershipServiceTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubMembershipServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def membership_path(project: str,location: str,membership: str,) -> str: - """Returns a fully-qualified membership string.""" - return "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) - - @staticmethod - def parse_membership_path(path: str) -> Dict[str,str]: - """Parses a membership path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?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, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - 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, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubMembershipServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub membership service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, GkeHubMembershipServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, GkeHubMembershipServiceTransport): - # transport is a GkeHubMembershipServiceTransport instance. - if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def list_memberships(self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsPager: - r"""Lists Memberships in a given project and location. - - Args: - request (google.cloud.gkehub_v1beta1.types.ListMembershipsRequest): - The request object. Request message for - `GkeHubMembershipService.ListMemberships` method. - parent (str): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/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.gkehub_v1beta1.services.gke_hub_membership_service.pagers.ListMembershipsPager: - Response message for the - GkeHubMembershipService.ListMemberships method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 membership.ListMembershipsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.ListMembershipsRequest): - request = membership.ListMembershipsRequest(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_memberships] - - # 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.ListMembershipsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_membership(self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: - r"""Gets the details of a Membership. - - Args: - request (google.cloud.gkehub_v1beta1.types.GetMembershipRequest): - The request object. Request message for - `GkeHubMembershipService.GetMembership` method. - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - 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.gkehub_v1beta1.types.Membership: - Membership contains information about - a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a membership.GetMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.GetMembershipRequest): - request = membership.GetMembershipRequest(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_membership] - - # 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 create_membership(self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Adds a new Membership. - - Args: - request (google.cloud.gkehub_v1beta1.types.CreateMembershipRequest): - The request object. Request message for the - `GkeHubMembershipService.CreateMembership` method. - parent (str): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1beta1.types.Membership): - Required. The membership to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - membership_id (str): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters - or ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length - of 63 characters. - - This corresponds to the ``membership_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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta1.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, membership_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 membership.CreateMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.CreateMembershipRequest): - request = membership.CreateMembershipRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if membership_id is not None: - request.membership_id = membership_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_membership] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_membership(self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Removes a Membership. - - Args: - request (google.cloud.gkehub_v1beta1.types.DeleteMembershipRequest): - The request object. Request message for - `GkeHubMembershipService.DeleteMembership` method. - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a membership.DeleteMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.DeleteMembershipRequest): - request = membership.DeleteMembershipRequest(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_membership] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_membership(self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates an existing Membership. - - Args: - request (google.cloud.gkehub_v1beta1.types.UpdateMembershipRequest): - The request object. Request message for - `GkeHubMembershipService.UpdateMembership` method. - name (str): - Required. The membership resource name in the format: - ``projects/[project_id]/locations/global/memberships/[membership_id]`` - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1beta1.types.Membership): - Required. Only fields specified in update_mask are - updated. If you specify a field in the update_mask but - don't specify its value here that field will be deleted. - If you are updating a map field, set the value of a key - to null or empty string to delete the key from the map. - It's not possible to update a key's value to the empty - string. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. - At least one field path must be - specified in this mask. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta1.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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 membership.UpdateMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.UpdateMembershipRequest): - request = membership.UpdateMembershipRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_membership] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def generate_connect_manifest(self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: - r"""Generates the manifest for deployment of the GKE - connect agent. - - Args: - request (google.cloud.gkehub_v1beta1.types.GenerateConnectManifestRequest): - The request object. Request message for - `GkeHubMembershipService.GenerateConnectManifest` - method. . - 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.gkehub_v1beta1.types.GenerateConnectManifestResponse: - GenerateConnectManifestResponse - contains manifest information for - installing/upgrading a Connect agent. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a membership.GenerateConnectManifestRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.GenerateConnectManifestRequest): - request = membership.GenerateConnectManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.generate_connect_manifest] - - # 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 validate_exclusivity(self, - request: membership.ValidateExclusivityRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.ValidateExclusivityResponse: - r"""ValidateExclusivity validates the state of - exclusivity in the cluster. The validation does not - depend on an existing Hub membership resource. - - Args: - request (google.cloud.gkehub_v1beta1.types.ValidateExclusivityRequest): - The request object. The request to validate the existing - state of the membership CR in the cluster. - 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.gkehub_v1beta1.types.ValidateExclusivityResponse: - The response of exclusivity artifacts - validation result status. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a membership.ValidateExclusivityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.ValidateExclusivityRequest): - request = membership.ValidateExclusivityRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.validate_exclusivity] - - # 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 generate_exclusivity_manifest(self, - request: membership.GenerateExclusivityManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateExclusivityManifestResponse: - r"""GenerateExclusivityManifest generates the manifests - to update the exclusivity artifacts in the cluster if - needed. - Exclusivity artifacts include the Membership custom - resource definition (CRD) and the singleton Membership - custom resource (CR). Combined with ValidateExclusivity, - exclusivity artifacts guarantee that a Kubernetes - cluster is only registered to a single GKE Hub. - - The Membership CRD is versioned, and may require - conversion when the GKE Hub API server begins serving a - newer version of the CRD and corresponding CR. The - response will be the converted CRD and CR if there are - any differences between the versions. - - Args: - request (google.cloud.gkehub_v1beta1.types.GenerateExclusivityManifestRequest): - The request object. The request to generate the - manifests for exclusivity artifacts. - 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.gkehub_v1beta1.types.GenerateExclusivityManifestResponse: - The response of the exclusivity - artifacts manifests for the client to - apply. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a membership.GenerateExclusivityManifestRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.GenerateExclusivityManifestRequest): - request = membership.GenerateExclusivityManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.generate_exclusivity_manifest] - - # 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 - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-gke-hub", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "GkeHubMembershipServiceClient", -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py deleted file mode 100644 index 05472ae..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/pagers.py +++ /dev/null @@ -1,140 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional - -from google.cloud.gkehub_v1beta1.types import membership - - -class ListMembershipsPager: - """A pager for iterating through ``list_memberships`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListMemberships`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` - 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[..., membership.ListMembershipsResponse], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - 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.gkehub_v1beta1.types.ListMembershipsRequest): - The initial request object. - response (google.cloud.gkehub_v1beta1.types.ListMembershipsResponse): - 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 = membership.ListMembershipsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[membership.ListMembershipsResponse]: - 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) -> Iterable[membership.Membership]: - for page in self.pages: - yield from page.resources - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListMembershipsAsyncPager: - """A pager for iterating through ``list_memberships`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListMemberships`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1beta1.types.ListMembershipsResponse` - 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[membership.ListMembershipsResponse]], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - 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.gkehub_v1beta1.types.ListMembershipsRequest): - The initial request object. - response (google.cloud.gkehub_v1beta1.types.ListMembershipsResponse): - 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 = membership.ListMembershipsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[membership.ListMembershipsResponse]: - 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) -> AsyncIterable[membership.Membership]: - async def async_generator(): - async for page in self.pages: - for response in page.resources: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py deleted file mode 100644 index 88ea247..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from typing import Dict, Type - -from .base import GkeHubMembershipServiceTransport -from .grpc import GkeHubMembershipServiceGrpcTransport -from .grpc_asyncio import GkeHubMembershipServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubMembershipServiceTransport]] -_transport_registry['grpc'] = GkeHubMembershipServiceGrpcTransport -_transport_registry['grpc_asyncio'] = GkeHubMembershipServiceGrpcAsyncIOTransport - -__all__ = ( - 'GkeHubMembershipServiceTransport', - 'GkeHubMembershipServiceGrpcTransport', - 'GkeHubMembershipServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py deleted file mode 100644 index 189e6dd..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/base.py +++ /dev/null @@ -1,273 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.gkehub_v1beta1.types import membership -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-gke-hub', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class GkeHubMembershipServiceTransport(abc.ABC): - """Abstract transport class for GkeHubMembershipService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'gkehub.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - 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' - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - - # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_memberships: gapic_v1.method.wrap_method( - self.list_memberships, - default_timeout=None, - client_info=client_info, - ), - self.get_membership: gapic_v1.method.wrap_method( - self.get_membership, - default_timeout=None, - client_info=client_info, - ), - self.create_membership: gapic_v1.method.wrap_method( - self.create_membership, - default_timeout=None, - client_info=client_info, - ), - self.delete_membership: gapic_v1.method.wrap_method( - self.delete_membership, - default_timeout=None, - client_info=client_info, - ), - self.update_membership: gapic_v1.method.wrap_method( - self.update_membership, - default_timeout=None, - client_info=client_info, - ), - self.generate_connect_manifest: gapic_v1.method.wrap_method( - self.generate_connect_manifest, - default_timeout=None, - client_info=client_info, - ), - self.validate_exclusivity: gapic_v1.method.wrap_method( - self.validate_exclusivity, - default_timeout=None, - client_info=client_info, - ), - self.generate_exclusivity_manifest: gapic_v1.method.wrap_method( - self.generate_exclusivity_manifest, - default_timeout=None, - client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - Union[ - membership.ListMembershipsResponse, - Awaitable[membership.ListMembershipsResponse] - ]]: - raise NotImplementedError() - - @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - Union[ - membership.Membership, - Awaitable[membership.Membership] - ]]: - raise NotImplementedError() - - @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - Union[ - membership.GenerateConnectManifestResponse, - Awaitable[membership.GenerateConnectManifestResponse] - ]]: - raise NotImplementedError() - - @property - def validate_exclusivity(self) -> Callable[ - [membership.ValidateExclusivityRequest], - Union[ - membership.ValidateExclusivityResponse, - Awaitable[membership.ValidateExclusivityResponse] - ]]: - raise NotImplementedError() - - @property - def generate_exclusivity_manifest(self) -> Callable[ - [membership.GenerateExclusivityManifestRequest], - Union[ - membership.GenerateExclusivityManifestResponse, - Awaitable[membership.GenerateExclusivityManifestResponse] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'GkeHubMembershipServiceTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py deleted file mode 100644 index c738350..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc.py +++ /dev/null @@ -1,468 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.gkehub_v1beta1.types import membership -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO - - -class GkeHubMembershipServiceGrpcTransport(GkeHubMembershipServiceTransport): - """gRPC backend transport for GkeHubMembershipService. - - GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - _stubs: Dict[str, Callable] - - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - membership.ListMembershipsResponse]: - r"""Return a callable for the list memberships method over gRPC. - - Lists Memberships in a given project and location. - - Returns: - Callable[[~.ListMembershipsRequest], - ~.ListMembershipsResponse]: - 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_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ListMemberships', - request_serializer=membership.ListMembershipsRequest.serialize, - response_deserializer=membership.ListMembershipsResponse.deserialize, - ) - return self._stubs['list_memberships'] - - @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - membership.Membership]: - r"""Return a callable for the get membership method over gRPC. - - Gets the details of a Membership. - - Returns: - Callable[[~.GetMembershipRequest], - ~.Membership]: - 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_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GetMembership', - request_serializer=membership.GetMembershipRequest.serialize, - response_deserializer=membership.Membership.deserialize, - ) - return self._stubs['get_membership'] - - @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - operations_pb2.Operation]: - r"""Return a callable for the create membership method over gRPC. - - Adds a new Membership. - - Returns: - Callable[[~.CreateMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/CreateMembership', - request_serializer=membership.CreateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_membership'] - - @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete membership method over gRPC. - - Removes a Membership. - - Returns: - Callable[[~.DeleteMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/DeleteMembership', - request_serializer=membership.DeleteMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_membership'] - - @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - operations_pb2.Operation]: - r"""Return a callable for the update membership method over gRPC. - - Updates an existing Membership. - - Returns: - Callable[[~.UpdateMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/UpdateMembership', - request_serializer=membership.UpdateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_membership'] - - @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - membership.GenerateConnectManifestResponse]: - r"""Return a callable for the generate connect manifest method over gRPC. - - Generates the manifest for deployment of the GKE - connect agent. - - Returns: - Callable[[~.GenerateConnectManifestRequest], - ~.GenerateConnectManifestResponse]: - 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 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateConnectManifest', - request_serializer=membership.GenerateConnectManifestRequest.serialize, - response_deserializer=membership.GenerateConnectManifestResponse.deserialize, - ) - return self._stubs['generate_connect_manifest'] - - @property - def validate_exclusivity(self) -> Callable[ - [membership.ValidateExclusivityRequest], - membership.ValidateExclusivityResponse]: - r"""Return a callable for the validate exclusivity method over gRPC. - - ValidateExclusivity validates the state of - exclusivity in the cluster. The validation does not - depend on an existing Hub membership resource. - - Returns: - Callable[[~.ValidateExclusivityRequest], - ~.ValidateExclusivityResponse]: - 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 'validate_exclusivity' not in self._stubs: - self._stubs['validate_exclusivity'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ValidateExclusivity', - request_serializer=membership.ValidateExclusivityRequest.serialize, - response_deserializer=membership.ValidateExclusivityResponse.deserialize, - ) - return self._stubs['validate_exclusivity'] - - @property - def generate_exclusivity_manifest(self) -> Callable[ - [membership.GenerateExclusivityManifestRequest], - membership.GenerateExclusivityManifestResponse]: - r"""Return a callable for the generate exclusivity manifest method over gRPC. - - GenerateExclusivityManifest generates the manifests - to update the exclusivity artifacts in the cluster if - needed. - Exclusivity artifacts include the Membership custom - resource definition (CRD) and the singleton Membership - custom resource (CR). Combined with ValidateExclusivity, - exclusivity artifacts guarantee that a Kubernetes - cluster is only registered to a single GKE Hub. - - The Membership CRD is versioned, and may require - conversion when the GKE Hub API server begins serving a - newer version of the CRD and corresponding CR. The - response will be the converted CRD and CR if there are - any differences between the versions. - - Returns: - Callable[[~.GenerateExclusivityManifestRequest], - ~.GenerateExclusivityManifestResponse]: - 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 'generate_exclusivity_manifest' not in self._stubs: - self._stubs['generate_exclusivity_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateExclusivityManifest', - request_serializer=membership.GenerateExclusivityManifestRequest.serialize, - response_deserializer=membership.GenerateExclusivityManifestResponse.deserialize, - ) - return self._stubs['generate_exclusivity_manifest'] - - -__all__ = ( - 'GkeHubMembershipServiceGrpcTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py deleted file mode 100644 index dc75184..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/gke_hub_membership_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,472 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.gkehub_v1beta1.types import membership -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubMembershipServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import GkeHubMembershipServiceGrpcTransport - - -class GkeHubMembershipServiceGrpcAsyncIOTransport(GkeHubMembershipServiceTransport): - """gRPC AsyncIO backend transport for GkeHubMembershipService. - - GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel(cls, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'gkehub.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_memberships(self) -> Callable[ - [membership.ListMembershipsRequest], - Awaitable[membership.ListMembershipsResponse]]: - r"""Return a callable for the list memberships method over gRPC. - - Lists Memberships in a given project and location. - - Returns: - Callable[[~.ListMembershipsRequest], - Awaitable[~.ListMembershipsResponse]]: - 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_memberships' not in self._stubs: - self._stubs['list_memberships'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ListMemberships', - request_serializer=membership.ListMembershipsRequest.serialize, - response_deserializer=membership.ListMembershipsResponse.deserialize, - ) - return self._stubs['list_memberships'] - - @property - def get_membership(self) -> Callable[ - [membership.GetMembershipRequest], - Awaitable[membership.Membership]]: - r"""Return a callable for the get membership method over gRPC. - - Gets the details of a Membership. - - Returns: - Callable[[~.GetMembershipRequest], - Awaitable[~.Membership]]: - 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_membership' not in self._stubs: - self._stubs['get_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GetMembership', - request_serializer=membership.GetMembershipRequest.serialize, - response_deserializer=membership.Membership.deserialize, - ) - return self._stubs['get_membership'] - - @property - def create_membership(self) -> Callable[ - [membership.CreateMembershipRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create membership method over gRPC. - - Adds a new Membership. - - Returns: - Callable[[~.CreateMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_membership' not in self._stubs: - self._stubs['create_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/CreateMembership', - request_serializer=membership.CreateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_membership'] - - @property - def delete_membership(self) -> Callable[ - [membership.DeleteMembershipRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete membership method over gRPC. - - Removes a Membership. - - Returns: - Callable[[~.DeleteMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_membership' not in self._stubs: - self._stubs['delete_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/DeleteMembership', - request_serializer=membership.DeleteMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_membership'] - - @property - def update_membership(self) -> Callable[ - [membership.UpdateMembershipRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update membership method over gRPC. - - Updates an existing Membership. - - Returns: - Callable[[~.UpdateMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_membership' not in self._stubs: - self._stubs['update_membership'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/UpdateMembership', - request_serializer=membership.UpdateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_membership'] - - @property - def generate_connect_manifest(self) -> Callable[ - [membership.GenerateConnectManifestRequest], - Awaitable[membership.GenerateConnectManifestResponse]]: - r"""Return a callable for the generate connect manifest method over gRPC. - - Generates the manifest for deployment of the GKE - connect agent. - - Returns: - Callable[[~.GenerateConnectManifestRequest], - Awaitable[~.GenerateConnectManifestResponse]]: - 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 'generate_connect_manifest' not in self._stubs: - self._stubs['generate_connect_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateConnectManifest', - request_serializer=membership.GenerateConnectManifestRequest.serialize, - response_deserializer=membership.GenerateConnectManifestResponse.deserialize, - ) - return self._stubs['generate_connect_manifest'] - - @property - def validate_exclusivity(self) -> Callable[ - [membership.ValidateExclusivityRequest], - Awaitable[membership.ValidateExclusivityResponse]]: - r"""Return a callable for the validate exclusivity method over gRPC. - - ValidateExclusivity validates the state of - exclusivity in the cluster. The validation does not - depend on an existing Hub membership resource. - - Returns: - Callable[[~.ValidateExclusivityRequest], - Awaitable[~.ValidateExclusivityResponse]]: - 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 'validate_exclusivity' not in self._stubs: - self._stubs['validate_exclusivity'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/ValidateExclusivity', - request_serializer=membership.ValidateExclusivityRequest.serialize, - response_deserializer=membership.ValidateExclusivityResponse.deserialize, - ) - return self._stubs['validate_exclusivity'] - - @property - def generate_exclusivity_manifest(self) -> Callable[ - [membership.GenerateExclusivityManifestRequest], - Awaitable[membership.GenerateExclusivityManifestResponse]]: - r"""Return a callable for the generate exclusivity manifest method over gRPC. - - GenerateExclusivityManifest generates the manifests - to update the exclusivity artifacts in the cluster if - needed. - Exclusivity artifacts include the Membership custom - resource definition (CRD) and the singleton Membership - custom resource (CR). Combined with ValidateExclusivity, - exclusivity artifacts guarantee that a Kubernetes - cluster is only registered to a single GKE Hub. - - The Membership CRD is versioned, and may require - conversion when the GKE Hub API server begins serving a - newer version of the CRD and corresponding CR. The - response will be the converted CRD and CR if there are - any differences between the versions. - - Returns: - Callable[[~.GenerateExclusivityManifestRequest], - Awaitable[~.GenerateExclusivityManifestResponse]]: - 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 'generate_exclusivity_manifest' not in self._stubs: - self._stubs['generate_exclusivity_manifest'] = self.grpc_channel.unary_unary( - '/google.cloud.gkehub.v1beta1.GkeHubMembershipService/GenerateExclusivityManifest', - request_serializer=membership.GenerateExclusivityManifestRequest.serialize, - response_deserializer=membership.GenerateExclusivityManifestResponse.deserialize, - ) - return self._stubs['generate_exclusivity_manifest'] - - -__all__ = ( - 'GkeHubMembershipServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py deleted file mode 100644 index 21cfed6..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .membership import ( - Authority, - ConnectAgent, - ConnectAgentResource, - CreateMembershipRequest, - DeleteMembershipRequest, - GenerateConnectManifestRequest, - GenerateConnectManifestResponse, - GenerateExclusivityManifestRequest, - GenerateExclusivityManifestResponse, - GetMembershipRequest, - GkeCluster, - KubernetesMetadata, - KubernetesResource, - ListMembershipsRequest, - ListMembershipsResponse, - Membership, - MembershipEndpoint, - MembershipState, - OperationMetadata, - ResourceManifest, - ResourceOptions, - TypeMeta, - UpdateMembershipRequest, - ValidateExclusivityRequest, - ValidateExclusivityResponse, -) - -__all__ = ( - 'Authority', - 'ConnectAgent', - 'ConnectAgentResource', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'GenerateExclusivityManifestRequest', - 'GenerateExclusivityManifestResponse', - 'GetMembershipRequest', - 'GkeCluster', - 'KubernetesMetadata', - 'KubernetesResource', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'Membership', - 'MembershipEndpoint', - 'MembershipState', - 'OperationMetadata', - 'ResourceManifest', - 'ResourceOptions', - 'TypeMeta', - 'UpdateMembershipRequest', - 'ValidateExclusivityRequest', - 'ValidateExclusivityResponse', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py b/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py deleted file mode 100644 index 8169b7a..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/types/membership.py +++ /dev/null @@ -1,1075 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.gkehub.v1beta1', - manifest={ - 'Membership', - 'MembershipEndpoint', - 'KubernetesResource', - 'ResourceOptions', - 'ResourceManifest', - 'GkeCluster', - 'KubernetesMetadata', - 'Authority', - 'MembershipState', - 'ListMembershipsRequest', - 'ListMembershipsResponse', - 'GetMembershipRequest', - 'CreateMembershipRequest', - 'DeleteMembershipRequest', - 'UpdateMembershipRequest', - 'GenerateConnectManifestRequest', - 'GenerateConnectManifestResponse', - 'ConnectAgentResource', - 'TypeMeta', - 'ConnectAgent', - 'ValidateExclusivityRequest', - 'ValidateExclusivityResponse', - 'GenerateExclusivityManifestRequest', - 'GenerateExclusivityManifestResponse', - 'OperationMetadata', - }, -) - - -class Membership(proto.Message): - r"""Membership contains information about a member cluster. - Attributes: - name (str): - Output only. The full, unique name of this Membership - resource in the format - ``projects/*/locations/*/memberships/{membership_id}``, set - during creation. - - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters or - ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of - 63 characters. - labels (Sequence[google.cloud.gkehub_v1beta1.types.Membership.LabelsEntry]): - Optional. GCP labels for this membership. - description (str): - Required. Description of this membership, limited to 63 - characters. Must match the regex: - ``[a-zA-Z0-9][a-zA-Z0-9_\-\.\ ]*`` - endpoint (google.cloud.gkehub_v1beta1.types.MembershipEndpoint): - Optional. Endpoint information to reach this - member. - state (google.cloud.gkehub_v1beta1.types.MembershipState): - Output only. State of the Membership - resource. - authority (google.cloud.gkehub_v1beta1.types.Authority): - Optional. How to identify workloads from this - Membership. See the documentation on Workload - Identity for more details: - https://cloud.google.com/kubernetes- - engine/docs/how-to/workload-identity - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was last - updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was deleted. - external_id (str): - Optional. An externally-generated and managed ID for this - Membership. This ID may be modified after creation, but this - is not recommended. For GKE clusters, external_id is managed - by the Hub API and updates will be ignored. - - The ID must match the regex: - ``[a-zA-Z0-9][a-zA-Z0-9_\-\.]*`` - - If this Membership represents a Kubernetes cluster, this - value should be set to the UID of the ``kube-system`` - namespace object. - last_connection_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. For clusters using Connect, the - timestamp of the most recent connection - established with Google Cloud. This time is - updated every several minutes, not continuously. - For clusters that do not use GKE Connect, or - that have never connected successfully, this - field will be unset. - unique_id (str): - Output only. Google-generated UUID for this resource. This - is unique across all Membership resources. If a Membership - resource is deleted and another resource with the same name - is created, it gets a different unique_id. - infrastructure_type (google.cloud.gkehub_v1beta1.types.Membership.InfrastructureType): - Optional. The infrastructure type this - Membership is running on. - """ - class InfrastructureType(proto.Enum): - r"""Specifies the infrastructure type of a Membership. - Infrastructure type is used by Hub to control infrastructure- - specific behavior, including pricing. - Each GKE distribution (on-GCP, on-Prem, on-X,...) will set this - field automatically, but Attached Clusters customers should - specify a type during registration. - """ - INFRASTRUCTURE_TYPE_UNSPECIFIED = 0 - ON_PREM = 1 - MULTI_CLOUD = 2 - - name = proto.Field( - proto.STRING, - number=1, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=2, - ) - description = proto.Field( - proto.STRING, - number=3, - ) - endpoint = proto.Field( - proto.MESSAGE, - number=4, - oneof='type', - message='MembershipEndpoint', - ) - state = proto.Field( - proto.MESSAGE, - number=5, - message='MembershipState', - ) - authority = proto.Field( - proto.MESSAGE, - number=9, - message='Authority', - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - external_id = proto.Field( - proto.STRING, - number=10, - ) - last_connection_time = proto.Field( - proto.MESSAGE, - number=11, - message=timestamp_pb2.Timestamp, - ) - unique_id = proto.Field( - proto.STRING, - number=12, - ) - infrastructure_type = proto.Field( - proto.ENUM, - number=13, - enum=InfrastructureType, - ) - - -class MembershipEndpoint(proto.Message): - r"""MembershipEndpoint contains information needed to contact a - Kubernetes API, endpoint and any additional Kubernetes metadata. - - Attributes: - gke_cluster (google.cloud.gkehub_v1beta1.types.GkeCluster): - Optional. GKE-specific information. Only - present if this Membership is a GKE cluster. - kubernetes_metadata (google.cloud.gkehub_v1beta1.types.KubernetesMetadata): - Output only. Useful Kubernetes-specific - metadata. - kubernetes_resource (google.cloud.gkehub_v1beta1.types.KubernetesResource): - Optional. The in-cluster Kubernetes Resources that should be - applied for a correctly registered cluster, in the steady - state. These resources: - - - Ensure that the cluster is exclusively registered to one - and only one Hub Membership. - - Propagate Workload Pool Information available in the - Membership Authority field. - - Ensure proper initial configuration of default Hub - Features. - """ - - gke_cluster = proto.Field( - proto.MESSAGE, - number=4, - message='GkeCluster', - ) - kubernetes_metadata = proto.Field( - proto.MESSAGE, - number=5, - message='KubernetesMetadata', - ) - kubernetes_resource = proto.Field( - proto.MESSAGE, - number=6, - message='KubernetesResource', - ) - - -class KubernetesResource(proto.Message): - r"""KubernetesResource contains the YAML manifests and - configuration for Membership Kubernetes resources in the - cluster. After CreateMembership or UpdateMembership, these - resources should be re-applied in the cluster. - - Attributes: - membership_cr_manifest (str): - Input only. The YAML representation of the - Membership CR. This field is ignored for GKE - clusters where Hub can read the CR directly. - Callers should provide the CR that is currently - present in the cluster during CreateMembership - or UpdateMembership, or leave this field empty - if none exists. The CR manifest is used to - validate the cluster has not been registered - with another Membership. - membership_resources (Sequence[google.cloud.gkehub_v1beta1.types.ResourceManifest]): - Output only. Additional Kubernetes resources - that need to be applied to the cluster after - Membership creation, and after every update. - This field is only populated in the Membership - returned from a successful long-running - operation from CreateMembership or - UpdateMembership. It is not populated during - normal GetMembership or ListMemberships - requests. To get the resource manifest after the - initial registration, the caller should make a - UpdateMembership call with an empty field mask. - connect_resources (Sequence[google.cloud.gkehub_v1beta1.types.ResourceManifest]): - Output only. The Kubernetes resources for - installing the GKE Connect agent - This field is only populated in the Membership - returned from a successful long-running - operation from CreateMembership or - UpdateMembership. It is not populated during - normal GetMembership or ListMemberships - requests. To get the resource manifest after the - initial registration, the caller should make a - UpdateMembership call with an empty field mask. - resource_options (google.cloud.gkehub_v1beta1.types.ResourceOptions): - Optional. Options for Kubernetes resource - generation. - """ - - membership_cr_manifest = proto.Field( - proto.STRING, - number=1, - ) - membership_resources = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ResourceManifest', - ) - connect_resources = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ResourceManifest', - ) - resource_options = proto.Field( - proto.MESSAGE, - number=4, - message='ResourceOptions', - ) - - -class ResourceOptions(proto.Message): - r"""ResourceOptions represent options for Kubernetes resource - generation. - - Attributes: - connect_version (str): - Optional. The Connect agent version to use for - connect_resources. Defaults to the latest GKE Connect - version. The version must be a currently supported version, - obsolete versions will be rejected. - v1beta1_crd (bool): - Optional. Use ``apiextensions/v1beta1`` instead of - ``apiextensions/v1`` for CustomResourceDefinition resources. - This option should be set for clusters with Kubernetes - apiserver versions <1.16. - """ - - connect_version = proto.Field( - proto.STRING, - number=1, - ) - v1beta1_crd = proto.Field( - proto.BOOL, - number=2, - ) - - -class ResourceManifest(proto.Message): - r"""ResourceManifest represents a single Kubernetes resource to - be applied to the cluster. - - Attributes: - manifest (str): - YAML manifest of the resource. - cluster_scoped (bool): - Whether the resource provided in the manifest is - ``cluster_scoped``. If unset, the manifest is assumed to be - namespace scoped. - - This field is used for REST mapping when applying the - resource in a cluster. - """ - - manifest = proto.Field( - proto.STRING, - number=1, - ) - cluster_scoped = proto.Field( - proto.BOOL, - number=2, - ) - - -class GkeCluster(proto.Message): - r"""GkeCluster contains information specific to GKE clusters. - Attributes: - resource_link (str): - Immutable. Self-link of the GCP resource for - the GKE cluster. For example: - > container.googleapis.com/projects/my- - project/locations/us-west1-a/clusters/my-cluster - Zonal clusters are also supported. - """ - - resource_link = proto.Field( - proto.STRING, - number=1, - ) - - -class KubernetesMetadata(proto.Message): - r"""KubernetesMetadata provides informational metadata for - Memberships representing Kubernetes clusters. - - Attributes: - kubernetes_api_server_version (str): - Output only. Kubernetes API server version - string as reported by '/version'. - node_provider_id (str): - Output only. Node providerID as reported by the first node - in the list of nodes on the Kubernetes endpoint. On - Kubernetes platforms that support zero-node clusters (like - GKE-on-GCP), the node_count will be zero and the - node_provider_id will be empty. - node_count (int): - Output only. Node count as reported by - Kubernetes nodes resources. - vcpu_count (int): - Output only. vCPU count as reported by - Kubernetes nodes resources. - memory_mb (int): - Output only. The total memory capacity as - reported by the sum of all Kubernetes nodes - resources, defined in MB. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which these details were last - updated. This update_time is different from the - Membership-level update_time since EndpointDetails are - updated internally for API consumers. - """ - - kubernetes_api_server_version = proto.Field( - proto.STRING, - number=1, - ) - node_provider_id = proto.Field( - proto.STRING, - number=2, - ) - node_count = proto.Field( - proto.INT32, - number=3, - ) - vcpu_count = proto.Field( - proto.INT32, - number=4, - ) - memory_mb = proto.Field( - proto.INT32, - number=5, - ) - update_time = proto.Field( - proto.MESSAGE, - number=100, - message=timestamp_pb2.Timestamp, - ) - - -class Authority(proto.Message): - r"""Authority encodes how Google will recognize identities from - this Membership. See the workload identity documentation for - more details: https://cloud.google.com/kubernetes- - engine/docs/how-to/workload-identity - - Attributes: - issuer (str): - Optional. A JSON Web Token (JWT) issuer URI. ``issuer`` must - start with ``https://`` and be a valid URL with length <2000 - characters. - - If set, then Google will allow valid OIDC tokens from this - issuer to authenticate within the workload_identity_pool. - OIDC discovery will be performed on this URI to validate - tokens from the issuer. - - Clearing ``issuer`` disables Workload Identity. ``issuer`` - cannot be directly modified; it must be cleared (and - Workload Identity disabled) before using a new issuer (and - re-enabling Workload Identity). - workload_identity_pool (str): - Output only. The name of the workload identity pool in which - ``issuer`` will be recognized. - - There is a single Workload Identity Pool per Hub that is - shared between all Memberships that belong to that Hub. For - a Hub hosted in {PROJECT_ID}, the workload pool format is - ``{PROJECT_ID}.hub.id.goog``, although this is subject to - change in newer versions of this API. - identity_provider (str): - Output only. An identity provider that reflects the - ``issuer`` in the workload identity pool. - oidc_jwks (bytes): - Optional. OIDC verification keys for this Membership in JWKS - format (RFC 7517). - - When this field is set, OIDC discovery will NOT be performed - on ``issuer``, and instead OIDC tokens will be validated - using this field. - """ - - issuer = proto.Field( - proto.STRING, - number=1, - ) - workload_identity_pool = proto.Field( - proto.STRING, - number=2, - ) - identity_provider = proto.Field( - proto.STRING, - number=3, - ) - oidc_jwks = proto.Field( - proto.BYTES, - number=4, - ) - - -class MembershipState(proto.Message): - r"""State of the Membership resource. - Attributes: - code (google.cloud.gkehub_v1beta1.types.MembershipState.Code): - Output only. The current state of the - Membership resource. - description (str): - This field is never set by the Hub Service. - update_time (google.protobuf.timestamp_pb2.Timestamp): - This field is never set by the Hub Service. - """ - class Code(proto.Enum): - r"""Code describes the state of a Membership resource.""" - CODE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - UPDATING = 4 - SERVICE_UPDATING = 5 - - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - - -class ListMembershipsRequest(proto.Message): - r"""Request message for ``GkeHubMembershipService.ListMemberships`` - method. - - Attributes: - parent (str): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/locations/*``. - page_size (int): - Optional. When requesting a 'page' of resources, - ``page_size`` specifies number of resources to return. If - unspecified or set to 0, all resources will be returned. - page_token (str): - Optional. Token returned by previous call to - ``ListMemberships`` which specifies the position in the list - from where to continue listing the resources. - filter (str): - Optional. Lists Memberships that match the filter - expression, following the syntax outlined in - https://google.aip.dev/160. - - Examples: - - - Name is ``bar`` in project ``foo-proj`` and location - ``global``: - - name = - "projects/foo-proj/locations/global/membership/bar" - - - Memberships that have a label called ``foo``: - - labels.foo:\* - - - Memberships that have a label called ``foo`` whose value - is ``bar``: - - labels.foo = bar - - - Memberships in the CREATING state: - - state = CREATING - order_by (str): - Optional. One or more fields to compare and - use to sort the output. See - https://google.aip.dev/132#ordering. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListMembershipsResponse(proto.Message): - r"""Response message for the ``GkeHubMembershipService.ListMemberships`` - method. - - Attributes: - resources (Sequence[google.cloud.gkehub_v1beta1.types.Membership]): - The list of matching Memberships. - next_page_token (str): - A token to request the next page of resources from the - ``ListMemberships`` method. The value of an empty string - means that there are no more resources to return. - unreachable (Sequence[str]): - List of locations that could not be reached - while fetching this list. - """ - - @property - def raw_page(self): - return self - - resources = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Membership', - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetMembershipRequest(proto.Message): - r"""Request message for ``GkeHubMembershipService.GetMembership`` - method. - - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateMembershipRequest(proto.Message): - r"""Request message for the ``GkeHubMembershipService.CreateMembership`` - method. - - Attributes: - parent (str): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - membership_id (str): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters or - ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of - 63 characters. - resource (google.cloud.gkehub_v1beta1.types.Membership): - Required. The membership to create. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - membership_id = proto.Field( - proto.STRING, - number=2, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message='Membership', - ) - - -class DeleteMembershipRequest(proto.Message): - r"""Request message for ``GkeHubMembershipService.DeleteMembership`` - method. - - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateMembershipRequest(proto.Message): - r"""Request message for ``GkeHubMembershipService.UpdateMembership`` - method. - - Attributes: - name (str): - Required. The membership resource name in the format: - ``projects/[project_id]/locations/global/memberships/[membership_id]`` - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. At least - one field path must be specified in this mask. - resource (google.cloud.gkehub_v1beta1.types.Membership): - Required. Only fields specified in update_mask are updated. - If you specify a field in the update_mask but don't specify - its value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - resource = proto.Field( - proto.MESSAGE, - number=3, - message='Membership', - ) - - -class GenerateConnectManifestRequest(proto.Message): - r"""Request message for - ``GkeHubMembershipService.GenerateConnectManifest`` method. . - - Attributes: - name (str): - Required. The Membership resource name the Agent will - associate with, in the format - ``projects/*/locations/*/memberships/*``. - connect_agent (google.cloud.gkehub_v1beta1.types.ConnectAgent): - Optional. The connect agent to generate - manifest for. - version (str): - Optional. The Connect agent version to use. - Defaults to the most current version. - is_upgrade (bool): - Optional. If true, generate the resources for - upgrade only. Some resources generated only for - installation (e.g. secrets) will be excluded. - registry (str): - Optional. The registry to fetch the connect - agent image from. Defaults to gcr.io/gkeconnect. - image_pull_secret_content (bytes): - Optional. The image pull secret content for - the registry, if not public. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - connect_agent = proto.Field( - proto.MESSAGE, - number=2, - message='ConnectAgent', - ) - version = proto.Field( - proto.STRING, - number=3, - ) - is_upgrade = proto.Field( - proto.BOOL, - number=4, - ) - registry = proto.Field( - proto.STRING, - number=5, - ) - image_pull_secret_content = proto.Field( - proto.BYTES, - number=6, - ) - - -class GenerateConnectManifestResponse(proto.Message): - r"""GenerateConnectManifestResponse contains manifest information - for installing/upgrading a Connect agent. - - Attributes: - manifest (Sequence[google.cloud.gkehub_v1beta1.types.ConnectAgentResource]): - The ordered list of Kubernetes resources that - need to be applied to the cluster for GKE - Connect agent installation/upgrade. - """ - - manifest = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ConnectAgentResource', - ) - - -class ConnectAgentResource(proto.Message): - r"""ConnectAgentResource represents a Kubernetes resource - manifest for Connect Agent deployment. - - Attributes: - type_ (google.cloud.gkehub_v1beta1.types.TypeMeta): - Kubernetes type of the resource. - manifest (str): - YAML manifest of the resource. - """ - - type_ = proto.Field( - proto.MESSAGE, - number=1, - message='TypeMeta', - ) - manifest = proto.Field( - proto.STRING, - number=2, - ) - - -class TypeMeta(proto.Message): - r"""TypeMeta is the type information needed for content - unmarshalling of Kubernetes resources in the manifest. - - Attributes: - kind (str): - Kind of the resource (e.g. Deployment). - api_version (str): - APIVersion of the resource (e.g. v1). - """ - - kind = proto.Field( - proto.STRING, - number=1, - ) - api_version = proto.Field( - proto.STRING, - number=2, - ) - - -class ConnectAgent(proto.Message): - r"""The information required from end users to use GKE Connect. - Attributes: - name (str): - Do not set. - proxy (bytes): - Optional. URI of a proxy if connectivity from the agent to - gkeconnect.googleapis.com requires the use of a proxy. - Format must be in the form ``http(s)://{proxy_address}``, - depending on the HTTP/HTTPS protocol supported by the proxy. - This will direct the connect agent's outbound traffic - through a HTTP(S) proxy. - namespace (str): - Optional. Namespace for GKE Connect agent resources. - Defaults to ``gke-connect``. - - The Connect Agent is authorized automatically when run in - the default namespace. Otherwise, explicit authorization - must be granted with an additional IAM binding. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - proxy = proto.Field( - proto.BYTES, - number=2, - ) - namespace = proto.Field( - proto.STRING, - number=3, - ) - - -class ValidateExclusivityRequest(proto.Message): - r"""The request to validate the existing state of the membership - CR in the cluster. - - Attributes: - parent (str): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - cr_manifest (str): - Optional. The YAML of the membership CR in - the cluster. Empty if the membership CR does not - exist. - intended_membership (str): - Required. The intended membership name under the ``parent``. - This method only does validation in anticipation of a - CreateMembership call with the same name. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - cr_manifest = proto.Field( - proto.STRING, - number=2, - ) - intended_membership = proto.Field( - proto.STRING, - number=3, - ) - - -class ValidateExclusivityResponse(proto.Message): - r"""The response of exclusivity artifacts validation result - status. - - Attributes: - status (google.rpc.status_pb2.Status): - The validation result. - - - ``OK`` means that exclusivity is validated, assuming the - manifest produced by GenerateExclusivityManifest is - successfully applied. - - ``ALREADY_EXISTS`` means that the Membership CRD is - already owned by another Hub. See ``status.message`` for - more information. - """ - - status = proto.Field( - proto.MESSAGE, - number=1, - message=status_pb2.Status, - ) - - -class GenerateExclusivityManifestRequest(proto.Message): - r"""The request to generate the manifests for exclusivity - artifacts. - - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - crd_manifest (str): - Optional. The YAML manifest of the membership CRD retrieved - by ``kubectl get customresourcedefinitions membership``. - Leave empty if the resource does not exist. - cr_manifest (str): - Optional. The YAML manifest of the membership CR retrieved - by ``kubectl get memberships membership``. Leave empty if - the resource does not exist. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - crd_manifest = proto.Field( - proto.STRING, - number=2, - ) - cr_manifest = proto.Field( - proto.STRING, - number=3, - ) - - -class GenerateExclusivityManifestResponse(proto.Message): - r"""The response of the exclusivity artifacts manifests for the - client to apply. - - Attributes: - crd_manifest (str): - The YAML manifest of the membership CRD to - apply if a newer version of the CRD is - available. Empty if no update needs to be - applied. - cr_manifest (str): - The YAML manifest of the membership CR to - apply if a new version of the CR is available. - Empty if no update needs to be applied. - """ - - crd_manifest = proto.Field( - proto.STRING, - number=1, - ) - cr_manifest = proto.Field( - proto.STRING, - number=2, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_detail (str): - Output only. Human-readable status of the - operation, if any. - cancel_requested (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_detail = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/mypy.ini b/owl-bot-staging/v1beta1/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1beta1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1beta1/noxfile.py b/owl-bot-staging/v1beta1/noxfile.py deleted file mode 100644 index 2db93fe..0000000 --- a/owl-bot-staging/v1beta1/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/gkehub_v1beta1/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py b/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py deleted file mode 100644 index b7bb67b..0000000 --- a/owl-bot-staging/v1beta1/scripts/fixup_gkehub_v1beta1_keywords.py +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class gkehubCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_membership': ('parent', 'membership_id', 'resource', ), - 'delete_membership': ('name', ), - 'generate_connect_manifest': ('name', 'connect_agent', 'version', 'is_upgrade', 'registry', 'image_pull_secret_content', ), - 'generate_exclusivity_manifest': ('name', 'crd_manifest', 'cr_manifest', ), - 'get_membership': ('name', ), - 'list_memberships': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_membership': ('name', 'update_mask', 'resource', ), - 'validate_exclusivity': ('parent', 'intended_membership', 'cr_manifest', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=gkehubCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the gkehub client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta1/setup.py b/owl-bot-staging/v1beta1/setup.py deleted file mode 100644 index 2c5fa00..0000000 --- a/owl-bot-staging/v1beta1/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-gke-hub', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1beta1/tests/__init__.py b/owl-bot-staging/v1beta1/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/__init__.py b/owl-bot-staging/v1beta1/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py b/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py deleted file mode 100644 index fe700b5..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py +++ /dev/null @@ -1,2803 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -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 operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import GkeHubMembershipServiceAsyncClient -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import GkeHubMembershipServiceClient -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import pagers -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service import transports -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.base import _GOOGLE_AUTH_VERSION -from google.cloud.gkehub_v1beta1.types import membership -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(None) is None - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert GkeHubMembershipServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - GkeHubMembershipServiceClient, - GkeHubMembershipServiceAsyncClient, -]) -def test_gke_hub_membership_service_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'gkehub.googleapis.com:443' - - -@pytest.mark.parametrize("client_class", [ - GkeHubMembershipServiceClient, - GkeHubMembershipServiceAsyncClient, -]) -def test_gke_hub_membership_service_client_service_account_always_use_jwt(client_class): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_called_with(True) - - -@pytest.mark.parametrize("client_class", [ - GkeHubMembershipServiceClient, - GkeHubMembershipServiceAsyncClient, -]) -def test_gke_hub_membership_service_client_from_service_account_file(client_class): - 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") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'gkehub.googleapis.com:443' - - -def test_gke_hub_membership_service_client_get_transport_class(): - transport = GkeHubMembershipServiceClient.get_transport_class() - available_transports = [ - transports.GkeHubMembershipServiceGrpcTransport, - ] - assert transport in available_transports - - transport = GkeHubMembershipServiceClient.get_transport_class("grpc") - assert transport == transports.GkeHubMembershipServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), - (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(GkeHubMembershipServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceClient)) -@mock.patch.object(GkeHubMembershipServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceAsyncClient)) -def test_gke_hub_membership_service_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubMembershipServiceClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubMembershipServiceClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc", "true"), - (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc", "false"), - (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(GkeHubMembershipServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceClient)) -@mock.patch.object(GkeHubMembershipServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubMembershipServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_membership_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), - (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_membership_service_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - 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) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubMembershipServiceClient, transports.GkeHubMembershipServiceGrpcTransport, "grpc"), - (GkeHubMembershipServiceAsyncClient, transports.GkeHubMembershipServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_membership_service_client_client_options_credentials_file(client_class, transport_class, transport_name): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_gke_hub_membership_service_client_client_options_from_dict(): - with mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = GkeHubMembershipServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_list_memberships(transport: str = 'grpc', request_type=membership.ListMembershipsRequest): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_memberships(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMembershipsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_memberships_from_dict(): - test_list_memberships(request_type=dict) - - -def test_list_memberships_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 = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - client.list_memberships() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - -@pytest.mark.asyncio -async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=membership.ListMembershipsRequest): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_memberships(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMembershipsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_memberships_async_from_dict(): - await test_list_memberships_async(request_type=dict) - - -def test_list_memberships_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.ListMembershipsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - call.return_value = membership.ListMembershipsResponse() - client.list_memberships(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_memberships_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.ListMembershipsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) - await client.list_memberships(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_memberships_flattened(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_memberships( - 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] - assert args[0].parent == 'parent_value' - - -def test_list_memberships_flattened_error(): - client = GkeHubMembershipServiceClient( - 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_memberships( - membership.ListMembershipsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_memberships_flattened_async(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_memberships( - 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] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_memberships_flattened_error_async(): - client = GkeHubMembershipServiceAsyncClient( - 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_memberships( - membership.ListMembershipsRequest(), - parent='parent_value', - ) - - -def test_list_memberships_pager(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_memberships(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, membership.Membership) - for i in results) - -def test_list_memberships_pages(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], - ), - RuntimeError, - ) - pages = list(client.list_memberships(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_memberships_async_pager(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_memberships(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, membership.Membership) - for i in responses) - -@pytest.mark.asyncio -async def test_list_memberships_async_pages(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_memberships(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_membership(transport: str = 'grpc', request_type=membership.GetMembershipRequest): - client = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', - infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), - ) - response = client.get_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' - assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM - - -def test_get_membership_from_dict(): - test_get_membership(request_type=dict) - - -def test_get_membership_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 = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - client.get_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - -@pytest.mark.asyncio -async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=membership.GetMembershipRequest): - client = GkeHubMembershipServiceAsyncClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', - infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - )) - response = await client.get_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' - assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM - - -@pytest.mark.asyncio -async def test_get_membership_async_from_dict(): - await test_get_membership_async(request_type=dict) - - -def test_get_membership_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.GetMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: - call.return_value = membership.Membership() - client.get_membership(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_membership_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.GetMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) - await client.get_membership(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_membership_flattened(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_membership( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_membership_flattened_error(): - client = GkeHubMembershipServiceClient( - 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_membership( - membership.GetMembershipRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_membership_flattened_async(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_membership( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_membership_flattened_error_async(): - client = GkeHubMembershipServiceAsyncClient( - 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_membership( - membership.GetMembershipRequest(), - name='name_value', - ) - - -def test_create_membership(transport: str = 'grpc', request_type=membership.CreateMembershipRequest): - client = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_membership_from_dict(): - test_create_membership(request_type=dict) - - -def test_create_membership_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 = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - client.create_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - -@pytest.mark.asyncio -async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=membership.CreateMembershipRequest): - client = GkeHubMembershipServiceAsyncClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_membership_async_from_dict(): - await test_create_membership_async(request_type=dict) - - -def test_create_membership_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.CreateMembershipRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_membership(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_membership_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.CreateMembershipRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_membership(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_membership_flattened(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_membership( - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].membership_id == 'membership_id_value' - - -def test_create_membership_flattened_error(): - client = GkeHubMembershipServiceClient( - 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_membership( - membership.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_membership_flattened_async(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_membership( - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].membership_id == 'membership_id_value' - - -@pytest.mark.asyncio -async def test_create_membership_flattened_error_async(): - client = GkeHubMembershipServiceAsyncClient( - 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_membership( - membership.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', - ) - - -def test_delete_membership(transport: str = 'grpc', request_type=membership.DeleteMembershipRequest): - client = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_membership_from_dict(): - test_delete_membership(request_type=dict) - - -def test_delete_membership_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 = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - client.delete_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - -@pytest.mark.asyncio -async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=membership.DeleteMembershipRequest): - client = GkeHubMembershipServiceAsyncClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_membership_async_from_dict(): - await test_delete_membership_async(request_type=dict) - - -def test_delete_membership_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.DeleteMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_membership(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_membership_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.DeleteMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_membership(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_membership_flattened(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_membership( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_membership_flattened_error(): - client = GkeHubMembershipServiceClient( - 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_membership( - membership.DeleteMembershipRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_membership_flattened_async(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_membership( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_membership_flattened_error_async(): - client = GkeHubMembershipServiceAsyncClient( - 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_membership( - membership.DeleteMembershipRequest(), - name='name_value', - ) - - -def test_update_membership(transport: str = 'grpc', request_type=membership.UpdateMembershipRequest): - client = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_membership_from_dict(): - test_update_membership(request_type=dict) - - -def test_update_membership_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 = GkeHubMembershipServiceClient( - 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_membership), - '__call__') as call: - client.update_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - -@pytest.mark.asyncio -async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=membership.UpdateMembershipRequest): - client = GkeHubMembershipServiceAsyncClient( - 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_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_membership_async_from_dict(): - await test_update_membership_async(request_type=dict) - - -def test_update_membership_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.UpdateMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_membership(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_update_membership_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.UpdateMembershipRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_membership(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_update_membership_flattened(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_membership( - name='name_value', - resource=membership.Membership(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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_membership_flattened_error(): - client = GkeHubMembershipServiceClient( - 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_membership( - membership.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_membership_flattened_async(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_membership( - name='name_value', - resource=membership.Membership(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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_membership_flattened_error_async(): - client = GkeHubMembershipServiceAsyncClient( - 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_membership( - membership.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_generate_connect_manifest(transport: str = 'grpc', request_type=membership.GenerateConnectManifestRequest): - client = GkeHubMembershipServiceClient( - 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.generate_connect_manifest), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.GenerateConnectManifestResponse( - ) - response = client.generate_connect_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateConnectManifestResponse) - - -def test_generate_connect_manifest_from_dict(): - test_generate_connect_manifest(request_type=dict) - - -def test_generate_connect_manifest_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 = GkeHubMembershipServiceClient( - 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.generate_connect_manifest), - '__call__') as call: - client.generate_connect_manifest() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - -@pytest.mark.asyncio -async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateConnectManifestRequest): - client = GkeHubMembershipServiceAsyncClient( - 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.generate_connect_manifest), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse( - )) - response = await client.generate_connect_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateConnectManifestResponse) - - -@pytest.mark.asyncio -async def test_generate_connect_manifest_async_from_dict(): - await test_generate_connect_manifest_async(request_type=dict) - - -def test_generate_connect_manifest_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.GenerateConnectManifestRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: - call.return_value = membership.GenerateConnectManifestResponse() - client.generate_connect_manifest(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_generate_connect_manifest_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.GenerateConnectManifestRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse()) - await client.generate_connect_manifest(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_validate_exclusivity(transport: str = 'grpc', request_type=membership.ValidateExclusivityRequest): - client = GkeHubMembershipServiceClient( - 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.validate_exclusivity), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ValidateExclusivityResponse( - ) - response = client.validate_exclusivity(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ValidateExclusivityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.ValidateExclusivityResponse) - - -def test_validate_exclusivity_from_dict(): - test_validate_exclusivity(request_type=dict) - - -def test_validate_exclusivity_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 = GkeHubMembershipServiceClient( - 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.validate_exclusivity), - '__call__') as call: - client.validate_exclusivity() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ValidateExclusivityRequest() - - -@pytest.mark.asyncio -async def test_validate_exclusivity_async(transport: str = 'grpc_asyncio', request_type=membership.ValidateExclusivityRequest): - client = GkeHubMembershipServiceAsyncClient( - 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.validate_exclusivity), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ValidateExclusivityResponse( - )) - response = await client.validate_exclusivity(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ValidateExclusivityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.ValidateExclusivityResponse) - - -@pytest.mark.asyncio -async def test_validate_exclusivity_async_from_dict(): - await test_validate_exclusivity_async(request_type=dict) - - -def test_validate_exclusivity_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.ValidateExclusivityRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_exclusivity), - '__call__') as call: - call.return_value = membership.ValidateExclusivityResponse() - client.validate_exclusivity(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_validate_exclusivity_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.ValidateExclusivityRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_exclusivity), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ValidateExclusivityResponse()) - await client.validate_exclusivity(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_generate_exclusivity_manifest(transport: str = 'grpc', request_type=membership.GenerateExclusivityManifestRequest): - client = GkeHubMembershipServiceClient( - 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.generate_exclusivity_manifest), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = membership.GenerateExclusivityManifestResponse( - crd_manifest='crd_manifest_value', - cr_manifest='cr_manifest_value', - ) - response = client.generate_exclusivity_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateExclusivityManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateExclusivityManifestResponse) - assert response.crd_manifest == 'crd_manifest_value' - assert response.cr_manifest == 'cr_manifest_value' - - -def test_generate_exclusivity_manifest_from_dict(): - test_generate_exclusivity_manifest(request_type=dict) - - -def test_generate_exclusivity_manifest_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 = GkeHubMembershipServiceClient( - 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.generate_exclusivity_manifest), - '__call__') as call: - client.generate_exclusivity_manifest() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateExclusivityManifestRequest() - - -@pytest.mark.asyncio -async def test_generate_exclusivity_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateExclusivityManifestRequest): - client = GkeHubMembershipServiceAsyncClient( - 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.generate_exclusivity_manifest), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateExclusivityManifestResponse( - crd_manifest='crd_manifest_value', - cr_manifest='cr_manifest_value', - )) - response = await client.generate_exclusivity_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateExclusivityManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateExclusivityManifestResponse) - assert response.crd_manifest == 'crd_manifest_value' - assert response.cr_manifest == 'cr_manifest_value' - - -@pytest.mark.asyncio -async def test_generate_exclusivity_manifest_async_from_dict(): - await test_generate_exclusivity_manifest_async(request_type=dict) - - -def test_generate_exclusivity_manifest_field_headers(): - client = GkeHubMembershipServiceClient( - 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 = membership.GenerateExclusivityManifestRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_exclusivity_manifest), - '__call__') as call: - call.return_value = membership.GenerateExclusivityManifestResponse() - client.generate_exclusivity_manifest(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_generate_exclusivity_manifest_field_headers_async(): - client = GkeHubMembershipServiceAsyncClient( - 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 = membership.GenerateExclusivityManifestRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_exclusivity_manifest), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateExclusivityManifestResponse()) - await client.generate_exclusivity_manifest(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_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.GkeHubMembershipServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.GkeHubMembershipServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubMembershipServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.GkeHubMembershipServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubMembershipServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubMembershipServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = GkeHubMembershipServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubMembershipServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.GkeHubMembershipServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.GkeHubMembershipServiceGrpcTransport, - transports.GkeHubMembershipServiceGrpcAsyncIOTransport, -]) -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() - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.GkeHubMembershipServiceGrpcTransport, - ) - -def test_gke_hub_membership_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.GkeHubMembershipServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_gke_hub_membership_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.GkeHubMembershipServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_memberships', - 'get_membership', - 'create_membership', - 'delete_membership', - 'update_membership', - 'generate_connect_manifest', - 'validate_exclusivity', - 'generate_exclusivity_manifest', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_membership_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('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubMembershipServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_membership_service_base_transport_with_credentials_file_old_google_auth(): - # 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('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubMembershipServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - quota_project_id="octopus", - ) - - -def test_gke_hub_membership_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.transports.GkeHubMembershipServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubMembershipServiceTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_membership_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubMembershipServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_membership_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubMembershipServiceClient() - adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.GkeHubMembershipServiceGrpcTransport, - transports.GkeHubMembershipServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_gte_1_25_0 -def test_gke_hub_membership_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.GkeHubMembershipServiceGrpcTransport, - transports.GkeHubMembershipServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_gke_hub_membership_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.GkeHubMembershipServiceGrpcTransport, grpc_helpers), - (transports.GkeHubMembershipServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_gke_hub_membership_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "gkehub.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=["1", "2"], - default_host="gkehub.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) -def test_gke_hub_membership_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - - -def test_gke_hub_membership_service_host_no_port(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), - ) - assert client.transport._host == 'gkehub.googleapis.com:443' - - -def test_gke_hub_membership_service_host_with_port(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), - ) - assert client.transport._host == 'gkehub.googleapis.com:8000' - -def test_gke_hub_membership_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubMembershipServiceGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_gke_hub_membership_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubMembershipServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) -def test_gke_hub_membership_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubMembershipServiceGrpcTransport, transports.GkeHubMembershipServiceGrpcAsyncIOTransport]) -def test_gke_hub_membership_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_gke_hub_membership_service_grpc_lro_client(): - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_gke_hub_membership_service_grpc_lro_async_client(): - client = GkeHubMembershipServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_membership_path(): - project = "squid" - location = "clam" - membership = "whelk" - expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) - actual = GkeHubMembershipServiceClient.membership_path(project, location, membership) - assert expected == actual - - -def test_parse_membership_path(): - expected = { - "project": "octopus", - "location": "oyster", - "membership": "nudibranch", - } - path = GkeHubMembershipServiceClient.membership_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_membership_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = GkeHubMembershipServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = GkeHubMembershipServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = GkeHubMembershipServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = GkeHubMembershipServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = GkeHubMembershipServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = GkeHubMembershipServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project, ) - actual = GkeHubMembershipServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = GkeHubMembershipServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = GkeHubMembershipServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = GkeHubMembershipServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubMembershipServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.GkeHubMembershipServiceTransport, '_prep_wrapped_messages') as prep: - client = GkeHubMembershipServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.GkeHubMembershipServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = GkeHubMembershipServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py b/scripts/fixup_cloudauditlogging_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_cloudauditlogging_v1alpha_keywords.py rename to scripts/fixup_cloudauditlogging_v1alpha_keywords.py diff --git a/owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py b/scripts/fixup_configmanagement_v1_keywords.py similarity index 100% rename from owl-bot-staging/v1/scripts/fixup_configmanagement_v1_keywords.py rename to scripts/fixup_configmanagement_v1_keywords.py diff --git a/owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py b/scripts/fixup_configmanagement_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_configmanagement_v1alpha_keywords.py rename to scripts/fixup_configmanagement_v1alpha_keywords.py diff --git a/owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py b/scripts/fixup_configmanagement_v1beta_keywords.py similarity index 100% rename from owl-bot-staging/v1beta/scripts/fixup_configmanagement_v1beta_keywords.py rename to scripts/fixup_configmanagement_v1beta_keywords.py diff --git a/owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py b/scripts/fixup_gkehub_v1_keywords.py similarity index 100% rename from owl-bot-staging/v1/scripts/fixup_gkehub_v1_keywords.py rename to scripts/fixup_gkehub_v1_keywords.py diff --git a/owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py b/scripts/fixup_gkehub_v1alpha2_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha2/scripts/fixup_gkehub_v1alpha2_keywords.py rename to scripts/fixup_gkehub_v1alpha2_keywords.py diff --git a/owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py b/scripts/fixup_gkehub_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_gkehub_v1alpha_keywords.py rename to scripts/fixup_gkehub_v1alpha_keywords.py diff --git a/owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py b/scripts/fixup_gkehub_v1beta_keywords.py similarity index 100% rename from owl-bot-staging/v1beta/scripts/fixup_gkehub_v1beta_keywords.py rename to scripts/fixup_gkehub_v1beta_keywords.py diff --git a/owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py b/scripts/fixup_metering_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_metering_v1alpha_keywords.py rename to scripts/fixup_metering_v1alpha_keywords.py diff --git a/owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py b/scripts/fixup_metering_v1beta_keywords.py similarity index 100% rename from owl-bot-staging/v1beta/scripts/fixup_metering_v1beta_keywords.py rename to scripts/fixup_metering_v1beta_keywords.py diff --git a/owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py b/scripts/fixup_multiclusteringress_v1_keywords.py similarity index 100% rename from owl-bot-staging/v1/scripts/fixup_multiclusteringress_v1_keywords.py rename to scripts/fixup_multiclusteringress_v1_keywords.py diff --git a/owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py b/scripts/fixup_multiclusteringress_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_multiclusteringress_v1alpha_keywords.py rename to scripts/fixup_multiclusteringress_v1alpha_keywords.py diff --git a/owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py b/scripts/fixup_multiclusteringress_v1beta_keywords.py similarity index 100% rename from owl-bot-staging/v1beta/scripts/fixup_multiclusteringress_v1beta_keywords.py rename to scripts/fixup_multiclusteringress_v1beta_keywords.py diff --git a/owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py b/scripts/fixup_servicemesh_v1alpha_keywords.py similarity index 100% rename from owl-bot-staging/v1alpha/scripts/fixup_servicemesh_v1alpha_keywords.py rename to scripts/fixup_servicemesh_v1alpha_keywords.py diff --git a/owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py b/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py similarity index 100% rename from owl-bot-staging/v1beta1/google/cloud/gkehub_v1beta1/services/__init__.py rename to tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py diff --git a/owl-bot-staging/v1/tests/unit/__init__.py b/tests/unit/gapic/configmanagement_v1/__init__.py similarity index 99% rename from owl-bot-staging/v1/tests/unit/__init__.py rename to tests/unit/gapic/configmanagement_v1/__init__.py index b54a5fc..4de6597 100644 --- a/owl-bot-staging/v1/tests/unit/__init__.py +++ b/tests/unit/gapic/configmanagement_v1/__init__.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Copyright 2020 Google LLC # diff --git a/owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py b/tests/unit/gapic/configmanagement_v1alpha/__init__.py similarity index 99% rename from owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py rename to tests/unit/gapic/configmanagement_v1alpha/__init__.py index b54a5fc..4de6597 100644 --- a/owl-bot-staging/v1/tests/unit/gapic/configmanagement_v1/__init__.py +++ b/tests/unit/gapic/configmanagement_v1alpha/__init__.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Copyright 2020 Google LLC # diff --git a/owl-bot-staging/v1/tests/unit/gapic/__init__.py b/tests/unit/gapic/configmanagement_v1beta/__init__.py similarity index 99% rename from owl-bot-staging/v1/tests/unit/gapic/__init__.py rename to tests/unit/gapic/configmanagement_v1beta/__init__.py index b54a5fc..4de6597 100644 --- a/owl-bot-staging/v1/tests/unit/gapic/__init__.py +++ b/tests/unit/gapic/configmanagement_v1beta/__init__.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Copyright 2020 Google LLC # diff --git a/owl-bot-staging/v1/tests/__init__.py b/tests/unit/gapic/gkehub_v1/__init__.py similarity index 99% rename from owl-bot-staging/v1/tests/__init__.py rename to tests/unit/gapic/gkehub_v1/__init__.py index b54a5fc..4de6597 100644 --- a/owl-bot-staging/v1/tests/__init__.py +++ b/tests/unit/gapic/gkehub_v1/__init__.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Copyright 2020 Google LLC # diff --git a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py b/tests/unit/gapic/gkehub_v1/test_gke_hub.py similarity index 64% rename from owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py rename to tests/unit/gapic/gkehub_v1/test_gke_hub.py index 87c99c6..8f10a97 100644 --- a/owl-bot-staging/v1/tests/unit/gapic/gkehub_v1/test_gke_hub.py +++ b/tests/unit/gapic/gkehub_v1/test_gke_hub.py @@ -64,6 +64,7 @@ reason="This test requires google-auth >= 1.25.0", ) + def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -72,7 +73,11 @@ def client_cert_source_callback(): # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) def test__get_default_mtls_endpoint(): @@ -84,46 +89,51 @@ def test__get_default_mtls_endpoint(): assert GkeHubClient._get_default_mtls_endpoint(None) is None assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ( + GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: factory.return_value = creds info = {"valid": True} client = client_class.from_service_account_info(info) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) use_jwt.assert_called_with(True) -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + 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") assert client.transport._credentials == creds @@ -133,7 +143,7 @@ def test_gke_hub_client_from_service_account_file(client_class): assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_client_get_transport_class(): @@ -147,29 +157,34 @@ def test_gke_hub_client_get_transport_class(): assert transport == transports.GkeHubGrpcTransport -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) def test_gke_hub_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: client = client_class(transport=transport_name) gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -185,7 +200,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -201,7 +216,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -221,13 +236,15 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client = client_class() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): with pytest.raises(ValueError): client = client_class() # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -240,24 +257,48 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): +def test_gke_hub_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) @@ -280,10 +321,18 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): if use_client_cert_env == "false": expected_host = client.DEFAULT_ENDPOINT expected_client_cert_source = None @@ -304,9 +353,14 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -320,16 +374,19 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_scopes( + client_class, transport_class, transport_name +): # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: + 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) patched.assert_called_once_with( @@ -342,16 +399,20 @@ def test_gke_hub_client_client_options_scopes(client_class, transport_class, tra client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_credentials_file( + client_class, transport_class, transport_name +): # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -366,11 +427,11 @@ def test_gke_hub_client_client_options_credentials_file(client_class, transport_ def test_gke_hub_client_client_options_from_dict(): - with mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + with mock.patch( + "google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubGrpcTransport.__init__" + ) as grpc_transport: grpc_transport.return_value = None - client = GkeHubClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) + client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) grpc_transport.assert_called_once_with( credentials=None, credentials_file=None, @@ -382,10 +443,11 @@ def test_gke_hub_client_client_options_from_dict(): ) -def test_list_memberships(transport: str = 'grpc', request_type=service.ListMembershipsRequest): +def test_list_memberships( + transport: str = "grpc", request_type=service.ListMembershipsRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -393,13 +455,10 @@ def test_list_memberships(transport: str = 'grpc', request_type=service.ListMemb request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], + next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) response = client.list_memberships(request) @@ -410,8 +469,8 @@ def test_list_memberships(transport: str = 'grpc', request_type=service.ListMemb # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMembershipsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] def test_list_memberships_from_dict(): @@ -422,14 +481,11 @@ def test_list_memberships_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: client.list_memberships() call.assert_called() _, args, _ = call.mock_calls[0] @@ -437,10 +493,11 @@ def test_list_memberships_empty_call(): @pytest.mark.asyncio -async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=service.ListMembershipsRequest): +async def test_list_memberships_async( + transport: str = "grpc_asyncio", request_type=service.ListMembershipsRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -448,14 +505,14 @@ async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_t request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListMembershipsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) response = await client.list_memberships(request) # Establish that the underlying gRPC stub method was called. @@ -465,8 +522,8 @@ async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_t # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMembershipsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio @@ -475,20 +532,16 @@ async def test_list_memberships_async_from_dict(): def test_list_memberships_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.ListMembershipsRequest() - 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_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: call.return_value = service.ListMembershipsResponse() client.list_memberships(request) @@ -499,29 +552,24 @@ def test_list_memberships_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 async def test_list_memberships_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.ListMembershipsRequest() - 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_memberships), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse()) + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListMembershipsResponse() + ) await client.list_memberships(request) # Establish that the underlying gRPC stub method was called. @@ -531,101 +579,78 @@ async def test_list_memberships_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_memberships_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListMembershipsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_memberships( - parent='parent_value', - ) + client.list_memberships(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" def test_list_memberships_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_memberships( - service.ListMembershipsRequest(), - parent='parent_value', + service.ListMembershipsRequest(), parent="parent_value", ) @pytest.mark.asyncio async def test_list_memberships_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListMembershipsResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListMembershipsResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListMembershipsResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_memberships( - parent='parent_value', - ) + response = await client.list_memberships(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_memberships_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_memberships( - service.ListMembershipsRequest(), - parent='parent_value', + service.ListMembershipsRequest(), parent="parent_value", ) def test_list_memberships_pager(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListMembershipsResponse( @@ -634,32 +659,21 @@ def test_list_memberships_pager(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', - ), - service.ListMembershipsResponse( - resources=[], - next_page_token='def', + next_page_token="abc", ), + service.ListMembershipsResponse(resources=[], next_page_token="def",), service.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', + resources=[membership.Membership(),], next_page_token="ghi", ), service.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) pager = client.list_memberships(request={}) @@ -667,18 +681,14 @@ def test_list_memberships_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, membership.Membership) - for i in results) + assert all(isinstance(i, membership.Membership) for i in results) + def test_list_memberships_pages(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListMembershipsResponse( @@ -687,40 +697,30 @@ def test_list_memberships_pages(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', + next_page_token="abc", ), + service.ListMembershipsResponse(resources=[], next_page_token="def",), service.ListMembershipsResponse( - resources=[], - next_page_token='def', + resources=[membership.Membership(),], next_page_token="ghi", ), service.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - service.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) pages = list(client.list_memberships(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token + @pytest.mark.asyncio async def test_list_memberships_async_pager(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListMembershipsResponse( @@ -729,46 +729,35 @@ async def test_list_memberships_async_pager(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', + next_page_token="abc", ), + service.ListMembershipsResponse(resources=[], next_page_token="def",), service.ListMembershipsResponse( - resources=[], - next_page_token='def', + resources=[membership.Membership(),], next_page_token="ghi", ), service.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - service.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) async_pager = await client.list_memberships(request={},) - assert async_pager.next_page_token == 'abc' + assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, membership.Membership) - for i in responses) + assert all(isinstance(i, membership.Membership) for i in responses) + @pytest.mark.asyncio async def test_list_memberships_async_pages(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListMembershipsResponse( @@ -777,36 +766,29 @@ async def test_list_memberships_async_pages(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', + next_page_token="abc", ), + service.ListMembershipsResponse(resources=[], next_page_token="def",), service.ListMembershipsResponse( - resources=[], - next_page_token='def', + resources=[membership.Membership(),], next_page_token="ghi", ), service.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - service.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) pages = [] async for page_ in (await client.list_memberships(request={})).pages: pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): + +def test_list_features( + transport: str = "grpc", request_type=service.ListFeaturesRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -814,12 +796,10 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse( - next_page_token='next_page_token_value', + next_page_token="next_page_token_value", ) response = client.list_features(request) @@ -830,7 +810,7 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" def test_list_features_from_dict(): @@ -841,14 +821,11 @@ def test_list_features_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: client.list_features() call.assert_called() _, args, _ = call.mock_calls[0] @@ -856,10 +833,11 @@ def test_list_features_empty_call(): @pytest.mark.asyncio -async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): +async def test_list_features_async( + transport: str = "grpc_asyncio", request_type=service.ListFeaturesRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -867,13 +845,11 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( - next_page_token='next_page_token_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse(next_page_token="next_page_token_value",) + ) response = await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -883,7 +859,7 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio @@ -892,20 +868,16 @@ async def test_list_features_async_from_dict(): def test_list_features_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: call.return_value = service.ListFeaturesResponse() client.list_features(request) @@ -916,29 +888,24 @@ def test_list_features_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 async def test_list_features_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + with mock.patch.object(type(client.transport.list_features), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -948,135 +915,97 @@ async def test_list_features_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_features_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_features( - parent='parent_value', - ) + client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" def test_list_features_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) @pytest.mark.asyncio async def test_list_features_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_features( - parent='parent_value', - ) + response = await client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_features_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) def test_list_features_pager(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) pager = client.list_features(request={}) @@ -1084,146 +1013,102 @@ def test_list_features_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, feature.Feature) - for i in results) + assert all(isinstance(i, feature.Feature) for i in results) + def test_list_features_pages(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = list(client.list_features(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token + @pytest.mark.asyncio async def test_list_features_async_pager(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) async_pager = await client.list_features(request={},) - assert async_pager.next_page_token == 'abc' + assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, feature.Feature) - for i in responses) + assert all(isinstance(i, feature.Feature) for i in responses) + @pytest.mark.asyncio async def test_list_features_async_pages(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = [] async for page_ in (await client.list_features(request={})).pages: pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_membership(transport: str = 'grpc', request_type=service.GetMembershipRequest): + +def test_get_membership( + transport: str = "grpc", request_type=service.GetMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1231,16 +1116,16 @@ def test_get_membership(transport: str = 'grpc', request_type=service.GetMembers request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', - endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), + name="name_value", + description="description_value", + external_id="external_id_value", + unique_id="unique_id_value", + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ), ) response = client.get_membership(request) @@ -1251,10 +1136,10 @@ def test_get_membership(transport: str = 'grpc', request_type=service.GetMembers # Establish that the response is the type that we expect. assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' + assert response.name == "name_value" + assert response.description == "description_value" + assert response.external_id == "external_id_value" + assert response.unique_id == "unique_id_value" def test_get_membership_from_dict(): @@ -1265,14 +1150,11 @@ def test_get_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: client.get_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1280,10 +1162,11 @@ def test_get_membership_empty_call(): @pytest.mark.asyncio -async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=service.GetMembershipRequest): +async def test_get_membership_async( + transport: str = "grpc_asyncio", request_type=service.GetMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1291,16 +1174,16 @@ async def test_get_membership_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership( + name="name_value", + description="description_value", + external_id="external_id_value", + unique_id="unique_id_value", + ) + ) response = await client.get_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1310,10 +1193,10 @@ async def test_get_membership_async(transport: str = 'grpc_asyncio', request_typ # Establish that the response is the type that we expect. assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' + assert response.name == "name_value" + assert response.description == "description_value" + assert response.external_id == "external_id_value" + assert response.unique_id == "unique_id_value" @pytest.mark.asyncio @@ -1322,20 +1205,16 @@ async def test_get_membership_async_from_dict(): def test_get_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.GetMembershipRequest() - 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_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: call.return_value = membership.Membership() client.get_membership(request) @@ -1346,29 +1225,24 @@ def test_get_membership_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 async def test_get_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.GetMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership() + ) await client.get_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1378,96 +1252,76 @@ async def test_get_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_get_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_membership( - name='name_value', - ) + client.get_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_get_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( - service.GetMembershipRequest(), - name='name_value', + service.GetMembershipRequest(), name="name_value", ) @pytest.mark.asyncio async def test_get_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_membership( - name='name_value', - ) + response = await client.get_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( - service.GetMembershipRequest(), - name='name_value', + service.GetMembershipRequest(), name="name_value", ) -def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): +def test_get_feature(transport: str = "grpc", request_type=service.GetFeatureRequest): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1475,13 +1329,9 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = feature.Feature( - name='name_value', - ) + call.return_value = feature.Feature(name="name_value",) response = client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1491,7 +1341,7 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" def test_get_feature_from_dict(): @@ -1502,14 +1352,11 @@ def test_get_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: client.get_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1517,10 +1364,11 @@ def test_get_feature_empty_call(): @pytest.mark.asyncio -async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): +async def test_get_feature_async( + transport: str = "grpc_asyncio", request_type=service.GetFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1528,13 +1376,11 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( - name='name_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + feature.Feature(name="name_value",) + ) response = await client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1544,7 +1390,7 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" @pytest.mark.asyncio @@ -1553,20 +1399,16 @@ async def test_get_feature_async_from_dict(): def test_get_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = feature.Feature() client.get_feature(request) @@ -1577,28 +1419,21 @@ def test_get_feature_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 async def test_get_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) await client.get_feature(request) @@ -1609,96 +1444,76 @@ async def test_get_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_get_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_feature( - name='name_value', - ) + client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_get_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_get_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_feature( - name='name_value', - ) + response = await client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) -def test_create_membership(transport: str = 'grpc', request_type=service.CreateMembershipRequest): +def test_create_membership( + transport: str = "grpc", request_type=service.CreateMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1707,10 +1522,10 @@ def test_create_membership(transport: str = 'grpc', request_type=service.CreateM # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1730,14 +1545,13 @@ def test_create_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: client.create_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1745,10 +1559,11 @@ def test_create_membership_empty_call(): @pytest.mark.asyncio -async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=service.CreateMembershipRequest): +async def test_create_membership_async( + transport: str = "grpc_asyncio", request_type=service.CreateMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1757,11 +1572,11 @@ async def test_create_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.create_membership(request) @@ -1780,21 +1595,19 @@ async def test_create_membership_async_from_dict(): def test_create_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.CreateMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.create_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1804,29 +1617,26 @@ def test_create_membership_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 async def test_create_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.CreateMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.create_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1836,110 +1646,132 @@ async def test_create_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_membership( - parent='parent_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + membership_id="membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) - assert args[0].membership_id == 'membership_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ) + ) + assert args[0].membership_id == "membership_id_value" def test_create_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( service.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + membership_id="membership_id_value", ) @pytest.mark.asyncio async def test_create_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_membership( - parent='parent_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + membership_id="membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) - assert args[0].membership_id == 'membership_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ) + ) + assert args[0].membership_id == "membership_id_value" @pytest.mark.asyncio async def test_create_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( service.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + membership_id="membership_id_value", ) -def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): +def test_create_feature( + transport: str = "grpc", request_type=service.CreateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1947,11 +1779,9 @@ def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1971,14 +1801,11 @@ def test_create_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: client.create_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1986,10 +1813,11 @@ def test_create_feature_empty_call(): @pytest.mark.asyncio -async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): +async def test_create_feature_async( + transport: str = "grpc_asyncio", request_type=service.CreateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1997,12 +1825,10 @@ async def test_create_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.create_feature(request) @@ -2020,22 +1846,18 @@ async def test_create_feature_async_from_dict(): await test_create_feature_async(request_type=dict) -def test_create_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) +def test_create_feature_field_headers(): + client = GkeHubClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2045,29 +1867,24 @@ def test_create_feature_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 async def test_create_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2077,110 +1894,96 @@ async def test_create_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" def test_create_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) @pytest.mark.asyncio async def test_create_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" @pytest.mark.asyncio async def test_create_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) -def test_delete_membership(transport: str = 'grpc', request_type=service.DeleteMembershipRequest): +def test_delete_membership( + transport: str = "grpc", request_type=service.DeleteMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2189,10 +1992,10 @@ def test_delete_membership(transport: str = 'grpc', request_type=service.DeleteM # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2212,14 +2015,13 @@ def test_delete_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: client.delete_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -2227,10 +2029,11 @@ def test_delete_membership_empty_call(): @pytest.mark.asyncio -async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=service.DeleteMembershipRequest): +async def test_delete_membership_async( + transport: str = "grpc_asyncio", request_type=service.DeleteMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2239,11 +2042,11 @@ async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.delete_membership(request) @@ -2262,21 +2065,19 @@ async def test_delete_membership_async_from_dict(): def test_delete_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.DeleteMembershipRequest() - 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.delete_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.delete_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2286,29 +2087,26 @@ def test_delete_membership_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 async def test_delete_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.DeleteMembershipRequest() - 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.delete_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.delete_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2318,98 +2116,82 @@ async def test_delete_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_delete_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_membership( - name='name_value', - ) + client.delete_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_delete_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( - service.DeleteMembershipRequest(), - name='name_value', + service.DeleteMembershipRequest(), name="name_value", ) @pytest.mark.asyncio async def test_delete_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_membership( - name='name_value', - ) + response = await client.delete_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( - service.DeleteMembershipRequest(), - name='name_value', + service.DeleteMembershipRequest(), name="name_value", ) -def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): +def test_delete_feature( + transport: str = "grpc", request_type=service.DeleteFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2417,11 +2199,9 @@ def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2441,14 +2221,11 @@ def test_delete_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: client.delete_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -2456,10 +2233,11 @@ def test_delete_feature_empty_call(): @pytest.mark.asyncio -async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): +async def test_delete_feature_async( + transport: str = "grpc_asyncio", request_type=service.DeleteFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2467,12 +2245,10 @@ async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.delete_feature(request) @@ -2491,21 +2267,17 @@ async def test_delete_feature_async_from_dict(): def test_delete_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2515,29 +2287,24 @@ def test_delete_feature_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 async def test_delete_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2547,98 +2314,78 @@ async def test_delete_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_delete_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_feature( - name='name_value', - ) + client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_delete_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_delete_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_feature( - name='name_value', - ) + response = await client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) -def test_update_membership(transport: str = 'grpc', request_type=service.UpdateMembershipRequest): +def test_update_membership( + transport: str = "grpc", request_type=service.UpdateMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2647,10 +2394,10 @@ def test_update_membership(transport: str = 'grpc', request_type=service.UpdateM # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2670,14 +2417,13 @@ def test_update_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: client.update_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -2685,10 +2431,11 @@ def test_update_membership_empty_call(): @pytest.mark.asyncio -async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=service.UpdateMembershipRequest): +async def test_update_membership_async( + transport: str = "grpc_asyncio", request_type=service.UpdateMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2697,11 +2444,11 @@ async def test_update_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.update_membership(request) @@ -2720,21 +2467,19 @@ async def test_update_membership_async_from_dict(): def test_update_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.UpdateMembershipRequest() - 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.update_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.update_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2744,29 +2489,26 @@ def test_update_membership_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 async def test_update_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.UpdateMembershipRequest() - 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.update_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.update_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -2776,110 +2518,132 @@ async def test_update_membership_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_update_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_membership( - name='name_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ) + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( service.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_membership( - name='name_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))) - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ) + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( service.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value'))), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership( + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster( + resource_link="resource_link_value" + ) + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): +def test_update_feature( + transport: str = "grpc", request_type=service.UpdateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2887,11 +2651,9 @@ def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2911,14 +2673,11 @@ def test_update_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: client.update_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -2926,10 +2685,11 @@ def test_update_feature_empty_call(): @pytest.mark.asyncio -async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): +async def test_update_feature_async( + transport: str = "grpc_asyncio", request_type=service.UpdateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2937,12 +2697,10 @@ async def test_update_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.update_feature(request) @@ -2961,21 +2719,17 @@ async def test_update_feature_async_from_dict(): def test_update_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -2985,29 +2739,24 @@ def test_update_feature_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 async def test_update_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -3017,110 +2766,96 @@ async def test_update_feature_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_update_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_generate_connect_manifest(transport: str = 'grpc', request_type=service.GenerateConnectManifestRequest): +def test_generate_connect_manifest( + transport: str = "grpc", request_type=service.GenerateConnectManifestRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3129,11 +2864,10 @@ def test_generate_connect_manifest(transport: str = 'grpc', request_type=service # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = service.GenerateConnectManifestResponse( - ) + call.return_value = service.GenerateConnectManifestResponse() response = client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -3153,14 +2887,13 @@ def test_generate_connect_manifest_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: client.generate_connect_manifest() call.assert_called() _, args, _ = call.mock_calls[0] @@ -3168,10 +2901,11 @@ def test_generate_connect_manifest_empty_call(): @pytest.mark.asyncio -async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=service.GenerateConnectManifestRequest): +async def test_generate_connect_manifest_async( + transport: str = "grpc_asyncio", request_type=service.GenerateConnectManifestRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3180,11 +2914,12 @@ async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.GenerateConnectManifestResponse( - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.GenerateConnectManifestResponse() + ) response = await client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -3202,20 +2937,18 @@ async def test_generate_connect_manifest_async_from_dict(): def test_generate_connect_manifest_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.GenerateConnectManifestRequest() - 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.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: call.return_value = service.GenerateConnectManifestResponse() client.generate_connect_manifest(request) @@ -3226,29 +2959,26 @@ def test_generate_connect_manifest_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 async def test_generate_connect_manifest_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.GenerateConnectManifestRequest() - 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.generate_connect_manifest), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.GenerateConnectManifestResponse()) + type(client.transport.generate_connect_manifest), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.GenerateConnectManifestResponse() + ) await client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -3258,10 +2988,7 @@ async def test_generate_connect_manifest_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(): @@ -3271,8 +2998,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - 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. @@ -3291,8 +3017,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + client_options={"scopes": ["1", "2"]}, transport=transport, ) @@ -3304,6 +3029,7 @@ def test_transport_instance(): client = GkeHubClient(transport=transport) assert client.transport is transport + def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.GkeHubGrpcTransport( @@ -3318,39 +3044,39 @@ def test_transport_get_channel(): channel = transport.grpc_channel assert channel -@pytest.mark.parametrize("transport_class", [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, -]) + +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], +) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.GkeHubGrpcTransport, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.GkeHubGrpcTransport,) + def test_gke_hub_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" + credentials_file="credentials.json", ) def test_gke_hub_base_transport(): # Instantiate the base transport. - with mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + with mock.patch( + "google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport.__init__" + ) as Transport: Transport.return_value = None transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3359,17 +3085,17 @@ def test_gke_hub_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. methods = ( - 'list_memberships', - 'list_features', - 'get_membership', - 'get_feature', - 'create_membership', - 'create_feature', - 'delete_membership', - 'delete_feature', - 'update_membership', - 'update_feature', - 'generate_connect_manifest', + "list_memberships", + "list_features", + "get_membership", + "get_feature", + "create_membership", + "create_feature", + "delete_membership", + "delete_feature", + "update_membership", + "update_feature", + "generate_connect_manifest", ) for method in methods: with pytest.raises(NotImplementedError): @@ -3384,18 +3110,20 @@ def test_gke_hub_base_transport(): @requires_google_auth_gte_1_25_0 def test_gke_hub_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('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", + load_creds.assert_called_once_with( + "credentials.json", scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -3403,23 +3131,28 @@ def test_gke_hub_base_transport_with_credentials_file(): @requires_google_auth_lt_1_25_0 def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): # 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('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_gke_hub_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.gkehub_v1.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport() @@ -3429,14 +3162,12 @@ def test_gke_hub_base_transport_with_adc(): @requires_google_auth_gte_1_25_0 def test_gke_hub_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @@ -3444,42 +3175,36 @@ def test_gke_hub_auth_adc(): @requires_google_auth_lt_1_25_0 def test_gke_hub_auth_adc_old_google_auth(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_gte_1_25_0 def test_gke_hub_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_lt_1_25_0 def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): @@ -3488,9 +3213,8 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -3499,30 +3223,27 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): "transport_class,grpc_helpers", [ (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), ], ) def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( grpc_helpers, "create_channel", autospec=True ) as create_channel: creds = ga_credentials.AnonymousCredentials() adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) create_channel.assert_called_with( "gkehub.googleapis.com:443", credentials=creds, credentials_file=None, quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), scopes=["1", "2"], default_host="gkehub.googleapis.com", ssl_credentials=None, @@ -3533,10 +3254,11 @@ def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. @@ -3545,7 +3267,7 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( transport_class( host="squid.clam.whelk", credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds + ssl_channel_credentials=mock_ssl_channel_creds, ) mock_create_channel.assert_called_once_with( "squid.clam.whelk:443", @@ -3566,37 +3288,40 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: transport_class( credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback + client_cert_source_for_mtls=client_cert_source_callback, ) expected_cert, expected_key = client_cert_source_callback() mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key + certificate_chain=expected_cert, private_key=expected_key ) def test_gke_hub_host_no_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_host_with_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com:8000" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:8000' + assert client.transport._host == "gkehub.googleapis.com:8000" + def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3604,12 +3329,11 @@ def test_gke_hub_grpc_transport_channel(): def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3618,12 +3342,17 @@ def test_gke_hub_grpc_asyncio_transport_channel(): # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -3632,7 +3361,7 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3662,17 +3391,20 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_adc( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_adc(transport_class): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() @@ -3702,16 +3434,12 @@ def test_gke_hub_transport_channel_mtls_with_adc( def test_gke_hub_grpc_lro_client(): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3719,16 +3447,12 @@ def test_gke_hub_grpc_lro_client(): def test_gke_hub_grpc_lro_async_client(): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3738,7 +3462,9 @@ def test_feature_path(): project = "squid" location = "clam" feature = "whelk" - expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + expected = "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) actual = GkeHubClient.feature_path(project, location, feature) assert expected == actual @@ -3755,11 +3481,14 @@ def test_parse_feature_path(): actual = GkeHubClient.parse_feature_path(path) assert expected == actual + def test_membership_path(): project = "cuttlefish" location = "mussel" membership = "winkle" - expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + expected = "projects/{project}/locations/{location}/memberships/{membership}".format( + project=project, location=location, membership=membership, + ) actual = GkeHubClient.membership_path(project, location, membership) assert expected == actual @@ -3776,9 +3505,12 @@ def test_parse_membership_path(): actual = GkeHubClient.parse_membership_path(path) assert expected == actual + def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) actual = GkeHubClient.common_billing_account_path(billing_account) assert expected == actual @@ -3793,9 +3525,10 @@ def test_parse_common_billing_account_path(): actual = GkeHubClient.parse_common_billing_account_path(path) assert expected == actual + def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder, ) + expected = "folders/{folder}".format(folder=folder,) actual = GkeHubClient.common_folder_path(folder) assert expected == actual @@ -3810,9 +3543,10 @@ def test_parse_common_folder_path(): actual = GkeHubClient.parse_common_folder_path(path) assert expected == actual + def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization, ) + expected = "organizations/{organization}".format(organization=organization,) actual = GkeHubClient.common_organization_path(organization) assert expected == actual @@ -3827,9 +3561,10 @@ def test_parse_common_organization_path(): actual = GkeHubClient.parse_common_organization_path(path) assert expected == actual + def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project, ) + expected = "projects/{project}".format(project=project,) actual = GkeHubClient.common_project_path(project) assert expected == actual @@ -3844,10 +3579,13 @@ def test_parse_common_project_path(): actual = GkeHubClient.parse_common_project_path(path) assert expected == actual + def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) actual = GkeHubClient.common_location_path(project, location) assert expected == actual @@ -3867,17 +3605,19 @@ def test_parse_common_location_path(): def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: transport_class = GkeHubClient.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) diff --git a/tests/unit/gapic/gkehub_v1alpha/__init__.py b/tests/unit/gapic/gkehub_v1alpha/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/gkehub_v1alpha/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py b/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py similarity index 66% rename from owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py rename to tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py index 41c5ee1..59e5484 100644 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py +++ b/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py @@ -43,7 +43,9 @@ from google.cloud.gkehub_v1alpha.services.gke_hub import GkeHubClient from google.cloud.gkehub_v1alpha.services.gke_hub import pagers from google.cloud.gkehub_v1alpha.services.gke_hub import transports -from google.cloud.gkehub_v1alpha.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1alpha.services.gke_hub.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.gkehub_v1alpha.types import feature from google.cloud.gkehub_v1alpha.types import service from google.longrunning import operations_pb2 @@ -67,6 +69,7 @@ reason="This test requires google-auth >= 1.25.0", ) + def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -75,7 +78,11 @@ def client_cert_source_callback(): # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) def test__get_default_mtls_endpoint(): @@ -87,46 +94,51 @@ def test__get_default_mtls_endpoint(): assert GkeHubClient._get_default_mtls_endpoint(None) is None assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ( + GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: factory.return_value = creds info = {"valid": True} client = client_class.from_service_account_info(info) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) use_jwt.assert_called_with(True) -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + 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") assert client.transport._credentials == creds @@ -136,7 +148,7 @@ def test_gke_hub_client_from_service_account_file(client_class): assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_client_get_transport_class(): @@ -150,29 +162,34 @@ def test_gke_hub_client_get_transport_class(): assert transport == transports.GkeHubGrpcTransport -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) def test_gke_hub_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: client = client_class(transport=transport_name) gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -188,7 +205,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -204,7 +221,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -224,13 +241,15 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client = client_class() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): with pytest.raises(ValueError): client = client_class() # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -243,24 +262,48 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): +def test_gke_hub_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) @@ -283,10 +326,18 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): if use_client_cert_env == "false": expected_host = client.DEFAULT_ENDPOINT expected_client_cert_source = None @@ -307,9 +358,14 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -323,16 +379,19 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_scopes( + client_class, transport_class, transport_name +): # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: + 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) patched.assert_called_once_with( @@ -345,16 +404,20 @@ def test_gke_hub_client_client_options_scopes(client_class, transport_class, tra client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_credentials_file( + client_class, transport_class, transport_name +): # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -369,11 +432,11 @@ def test_gke_hub_client_client_options_credentials_file(client_class, transport_ def test_gke_hub_client_client_options_from_dict(): - with mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + with mock.patch( + "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubGrpcTransport.__init__" + ) as grpc_transport: grpc_transport.return_value = None - client = GkeHubClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) + client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) grpc_transport.assert_called_once_with( credentials=None, credentials_file=None, @@ -385,10 +448,11 @@ def test_gke_hub_client_client_options_from_dict(): ) -def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): +def test_list_features( + transport: str = "grpc", request_type=service.ListFeaturesRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -396,12 +460,10 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse( - next_page_token='next_page_token_value', + next_page_token="next_page_token_value", ) response = client.list_features(request) @@ -412,7 +474,7 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" def test_list_features_from_dict(): @@ -423,14 +485,11 @@ def test_list_features_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: client.list_features() call.assert_called() _, args, _ = call.mock_calls[0] @@ -438,10 +497,11 @@ def test_list_features_empty_call(): @pytest.mark.asyncio -async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): +async def test_list_features_async( + transport: str = "grpc_asyncio", request_type=service.ListFeaturesRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -449,13 +509,11 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( - next_page_token='next_page_token_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse(next_page_token="next_page_token_value",) + ) response = await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -465,7 +523,7 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio @@ -474,20 +532,16 @@ async def test_list_features_async_from_dict(): def test_list_features_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: call.return_value = service.ListFeaturesResponse() client.list_features(request) @@ -498,29 +552,24 @@ def test_list_features_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 async def test_list_features_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + with mock.patch.object(type(client.transport.list_features), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -530,135 +579,97 @@ async def test_list_features_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_features_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_features( - parent='parent_value', - ) + client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" def test_list_features_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) @pytest.mark.asyncio async def test_list_features_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_features( - parent='parent_value', - ) + response = await client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_features_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) def test_list_features_pager(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) pager = client.list_features(request={}) @@ -666,146 +677,100 @@ def test_list_features_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, feature.Feature) - for i in results) + assert all(isinstance(i, feature.Feature) for i in results) + def test_list_features_pages(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = list(client.list_features(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token + @pytest.mark.asyncio async def test_list_features_async_pager(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) async_pager = await client.list_features(request={},) - assert async_pager.next_page_token == 'abc' + assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, feature.Feature) - for i in responses) + assert all(isinstance(i, feature.Feature) for i in responses) + @pytest.mark.asyncio async def test_list_features_async_pages(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = [] async for page_ in (await client.list_features(request={})).pages: pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): + +def test_get_feature(transport: str = "grpc", request_type=service.GetFeatureRequest): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -813,13 +778,9 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = feature.Feature( - name='name_value', - ) + call.return_value = feature.Feature(name="name_value",) response = client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -829,7 +790,7 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" def test_get_feature_from_dict(): @@ -840,14 +801,11 @@ def test_get_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: client.get_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -855,10 +813,11 @@ def test_get_feature_empty_call(): @pytest.mark.asyncio -async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): +async def test_get_feature_async( + transport: str = "grpc_asyncio", request_type=service.GetFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -866,13 +825,11 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( - name='name_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + feature.Feature(name="name_value",) + ) response = await client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -882,7 +839,7 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" @pytest.mark.asyncio @@ -891,20 +848,16 @@ async def test_get_feature_async_from_dict(): def test_get_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = feature.Feature() client.get_feature(request) @@ -915,28 +868,21 @@ def test_get_feature_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 async def test_get_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) await client.get_feature(request) @@ -947,96 +893,76 @@ async def test_get_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_get_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_feature( - name='name_value', - ) + client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_get_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_get_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_feature( - name='name_value', - ) + response = await client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) -def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): +def test_create_feature( + transport: str = "grpc", request_type=service.CreateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1044,11 +970,9 @@ def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1068,14 +992,11 @@ def test_create_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: client.create_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1083,10 +1004,11 @@ def test_create_feature_empty_call(): @pytest.mark.asyncio -async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): +async def test_create_feature_async( + transport: str = "grpc_asyncio", request_type=service.CreateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1094,12 +1016,10 @@ async def test_create_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.create_feature(request) @@ -1118,21 +1038,17 @@ async def test_create_feature_async_from_dict(): def test_create_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1142,29 +1058,24 @@ def test_create_feature_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 async def test_create_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1174,110 +1085,96 @@ async def test_create_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" def test_create_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) @pytest.mark.asyncio async def test_create_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" @pytest.mark.asyncio async def test_create_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) -def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): +def test_delete_feature( + transport: str = "grpc", request_type=service.DeleteFeatureRequest +): client = GkeHubClient( - 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,11 +1182,9 @@ def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1309,14 +1204,11 @@ def test_delete_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: client.delete_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1324,10 +1216,11 @@ def test_delete_feature_empty_call(): @pytest.mark.asyncio -async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): +async def test_delete_feature_async( + transport: str = "grpc_asyncio", request_type=service.DeleteFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1335,12 +1228,10 @@ async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.delete_feature(request) @@ -1359,21 +1250,17 @@ async def test_delete_feature_async_from_dict(): def test_delete_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1383,29 +1270,24 @@ def test_delete_feature_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 async def test_delete_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1415,98 +1297,78 @@ async def test_delete_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_delete_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_feature( - name='name_value', - ) + client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_delete_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_delete_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_feature( - name='name_value', - ) + response = await client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) -def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): +def test_update_feature( + transport: str = "grpc", request_type=service.UpdateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1514,11 +1376,9 @@ def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1538,14 +1398,11 @@ def test_update_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: client.update_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1553,10 +1410,11 @@ def test_update_feature_empty_call(): @pytest.mark.asyncio -async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): +async def test_update_feature_async( + transport: str = "grpc_asyncio", request_type=service.UpdateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1564,12 +1422,10 @@ async def test_update_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.update_feature(request) @@ -1588,21 +1444,17 @@ async def test_update_feature_async_from_dict(): def test_update_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1612,29 +1464,24 @@ def test_update_feature_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 async def test_update_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1644,103 +1491,88 @@ async def test_update_feature_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_update_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1751,8 +1583,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - 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. @@ -1771,8 +1602,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + client_options={"scopes": ["1", "2"]}, transport=transport, ) @@ -1784,6 +1614,7 @@ def test_transport_instance(): client = GkeHubClient(transport=transport) assert client.transport is transport + def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.GkeHubGrpcTransport( @@ -1798,39 +1629,39 @@ def test_transport_get_channel(): channel = transport.grpc_channel assert channel -@pytest.mark.parametrize("transport_class", [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, -]) + +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], +) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.GkeHubGrpcTransport, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.GkeHubGrpcTransport,) + def test_gke_hub_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" + credentials_file="credentials.json", ) def test_gke_hub_base_transport(): # Instantiate the base transport. - with mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + with mock.patch( + "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport.__init__" + ) as Transport: Transport.return_value = None transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1839,11 +1670,11 @@ def test_gke_hub_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. methods = ( - 'list_features', - 'get_feature', - 'create_feature', - 'delete_feature', - 'update_feature', + "list_features", + "get_feature", + "create_feature", + "delete_feature", + "update_feature", ) for method in methods: with pytest.raises(NotImplementedError): @@ -1858,18 +1689,20 @@ def test_gke_hub_base_transport(): @requires_google_auth_gte_1_25_0 def test_gke_hub_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('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", + load_creds.assert_called_once_with( + "credentials.json", scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -1877,23 +1710,28 @@ def test_gke_hub_base_transport_with_credentials_file(): @requires_google_auth_lt_1_25_0 def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): # 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('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_gke_hub_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport() @@ -1903,14 +1741,12 @@ def test_gke_hub_base_transport_with_adc(): @requires_google_auth_gte_1_25_0 def test_gke_hub_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @@ -1918,42 +1754,36 @@ def test_gke_hub_auth_adc(): @requires_google_auth_lt_1_25_0 def test_gke_hub_auth_adc_old_google_auth(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_gte_1_25_0 def test_gke_hub_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_lt_1_25_0 def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): @@ -1962,9 +1792,8 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -1973,30 +1802,27 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): "transport_class,grpc_helpers", [ (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), ], ) def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( grpc_helpers, "create_channel", autospec=True ) as create_channel: creds = ga_credentials.AnonymousCredentials() adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) create_channel.assert_called_with( "gkehub.googleapis.com:443", credentials=creds, credentials_file=None, quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), scopes=["1", "2"], default_host="gkehub.googleapis.com", ssl_credentials=None, @@ -2007,10 +1833,11 @@ def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. @@ -2019,7 +1846,7 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( transport_class( host="squid.clam.whelk", credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds + ssl_channel_credentials=mock_ssl_channel_creds, ) mock_create_channel.assert_called_once_with( "squid.clam.whelk:443", @@ -2040,37 +1867,40 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: transport_class( credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback + client_cert_source_for_mtls=client_cert_source_callback, ) expected_cert, expected_key = client_cert_source_callback() mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key + certificate_chain=expected_cert, private_key=expected_key ) def test_gke_hub_host_no_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_host_with_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com:8000" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:8000' + assert client.transport._host == "gkehub.googleapis.com:8000" + def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2078,12 +1908,11 @@ def test_gke_hub_grpc_transport_channel(): def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2092,12 +1921,17 @@ def test_gke_hub_grpc_asyncio_transport_channel(): # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -2106,7 +1940,7 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2136,17 +1970,20 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_adc( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_adc(transport_class): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() @@ -2176,16 +2013,12 @@ def test_gke_hub_transport_channel_mtls_with_adc( def test_gke_hub_grpc_lro_client(): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2193,16 +2026,12 @@ def test_gke_hub_grpc_lro_client(): def test_gke_hub_grpc_lro_async_client(): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2212,7 +2041,9 @@ def test_feature_path(): project = "squid" location = "clam" feature = "whelk" - expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + expected = "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) actual = GkeHubClient.feature_path(project, location, feature) assert expected == actual @@ -2229,9 +2060,12 @@ def test_parse_feature_path(): actual = GkeHubClient.parse_feature_path(path) assert expected == actual + def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) actual = GkeHubClient.common_billing_account_path(billing_account) assert expected == actual @@ -2246,9 +2080,10 @@ def test_parse_common_billing_account_path(): actual = GkeHubClient.parse_common_billing_account_path(path) assert expected == actual + def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) + expected = "folders/{folder}".format(folder=folder,) actual = GkeHubClient.common_folder_path(folder) assert expected == actual @@ -2263,9 +2098,10 @@ def test_parse_common_folder_path(): actual = GkeHubClient.parse_common_folder_path(path) assert expected == actual + def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) + expected = "organizations/{organization}".format(organization=organization,) actual = GkeHubClient.common_organization_path(organization) assert expected == actual @@ -2280,9 +2116,10 @@ def test_parse_common_organization_path(): actual = GkeHubClient.parse_common_organization_path(path) assert expected == actual + def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project, ) + expected = "projects/{project}".format(project=project,) actual = GkeHubClient.common_project_path(project) assert expected == actual @@ -2297,10 +2134,13 @@ def test_parse_common_project_path(): actual = GkeHubClient.parse_common_project_path(path) assert expected == actual + def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) actual = GkeHubClient.common_location_path(project, location) assert expected == actual @@ -2320,17 +2160,19 @@ def test_parse_common_location_path(): def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: transport_class = GkeHubClient.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) diff --git a/tests/unit/gapic/gkehub_v1alpha2/__init__.py b/tests/unit/gapic/gkehub_v1alpha2/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/gkehub_v1alpha2/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py b/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py similarity index 66% rename from owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py rename to tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py index bf6e3b1..b6cbfcd 100644 --- a/owl-bot-staging/v1alpha2/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py +++ b/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py @@ -38,7 +38,9 @@ from google.cloud.gkehub_v1alpha2.services.gke_hub import GkeHubClient from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers from google.cloud.gkehub_v1alpha2.services.gke_hub import transports -from google.cloud.gkehub_v1alpha2.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1alpha2.services.gke_hub.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.gkehub_v1alpha2.types import membership from google.longrunning import operations_pb2 from google.oauth2 import service_account @@ -60,6 +62,7 @@ reason="This test requires google-auth >= 1.25.0", ) + def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -68,7 +71,11 @@ def client_cert_source_callback(): # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) def test__get_default_mtls_endpoint(): @@ -80,46 +87,51 @@ def test__get_default_mtls_endpoint(): assert GkeHubClient._get_default_mtls_endpoint(None) is None assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ( + GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: factory.return_value = creds info = {"valid": True} client = client_class.from_service_account_info(info) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) use_jwt.assert_called_with(True) -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + 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") assert client.transport._credentials == creds @@ -129,7 +141,7 @@ def test_gke_hub_client_from_service_account_file(client_class): assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_client_get_transport_class(): @@ -143,29 +155,34 @@ def test_gke_hub_client_get_transport_class(): assert transport == transports.GkeHubGrpcTransport -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) def test_gke_hub_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: client = client_class(transport=transport_name) gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -181,7 +198,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -197,7 +214,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -217,13 +234,15 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client = client_class() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): with pytest.raises(ValueError): client = client_class() # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -236,24 +255,48 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): +def test_gke_hub_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) @@ -276,10 +319,18 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): if use_client_cert_env == "false": expected_host = client.DEFAULT_ENDPOINT expected_client_cert_source = None @@ -300,9 +351,14 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -316,16 +372,19 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_scopes( + client_class, transport_class, transport_name +): # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: + 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) patched.assert_called_once_with( @@ -338,16 +397,20 @@ def test_gke_hub_client_client_options_scopes(client_class, transport_class, tra client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_credentials_file( + client_class, transport_class, transport_name +): # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -362,11 +425,11 @@ def test_gke_hub_client_client_options_credentials_file(client_class, transport_ def test_gke_hub_client_client_options_from_dict(): - with mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + with mock.patch( + "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubGrpcTransport.__init__" + ) as grpc_transport: grpc_transport.return_value = None - client = GkeHubClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) + client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) grpc_transport.assert_called_once_with( credentials=None, credentials_file=None, @@ -378,10 +441,11 @@ def test_gke_hub_client_client_options_from_dict(): ) -def test_list_memberships(transport: str = 'grpc', request_type=membership.ListMembershipsRequest): +def test_list_memberships( + transport: str = "grpc", request_type=membership.ListMembershipsRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -389,13 +453,10 @@ def test_list_memberships(transport: str = 'grpc', request_type=membership.ListM request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], + next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) response = client.list_memberships(request) @@ -406,8 +467,8 @@ def test_list_memberships(transport: str = 'grpc', request_type=membership.ListM # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMembershipsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] def test_list_memberships_from_dict(): @@ -418,14 +479,11 @@ def test_list_memberships_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: client.list_memberships() call.assert_called() _, args, _ = call.mock_calls[0] @@ -433,10 +491,11 @@ def test_list_memberships_empty_call(): @pytest.mark.asyncio -async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_type=membership.ListMembershipsRequest): +async def test_list_memberships_async( + transport: str = "grpc_asyncio", request_type=membership.ListMembershipsRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -444,14 +503,14 @@ async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_t request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.ListMembershipsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) response = await client.list_memberships(request) # Establish that the underlying gRPC stub method was called. @@ -461,8 +520,8 @@ async def test_list_memberships_async(transport: str = 'grpc_asyncio', request_t # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMembershipsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio @@ -471,20 +530,16 @@ async def test_list_memberships_async_from_dict(): def test_list_memberships_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.ListMembershipsRequest() - 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_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: call.return_value = membership.ListMembershipsResponse() client.list_memberships(request) @@ -495,29 +550,24 @@ def test_list_memberships_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 async def test_list_memberships_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.ListMembershipsRequest() - 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_memberships), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.ListMembershipsResponse() + ) await client.list_memberships(request) # Establish that the underlying gRPC stub method was called. @@ -527,101 +577,78 @@ async def test_list_memberships_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_memberships_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.ListMembershipsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_memberships( - parent='parent_value', - ) + client.list_memberships(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" def test_list_memberships_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_memberships( - membership.ListMembershipsRequest(), - parent='parent_value', + membership.ListMembershipsRequest(), parent="parent_value", ) @pytest.mark.asyncio async def test_list_memberships_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.ListMembershipsResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.ListMembershipsResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.ListMembershipsResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_memberships( - parent='parent_value', - ) + response = await client.list_memberships(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_memberships_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_memberships( - membership.ListMembershipsRequest(), - parent='parent_value', + membership.ListMembershipsRequest(), parent="parent_value", ) def test_list_memberships_pager(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( membership.ListMembershipsResponse( @@ -630,32 +657,21 @@ def test_list_memberships_pager(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', + next_page_token="abc", ), + membership.ListMembershipsResponse(resources=[], next_page_token="def",), membership.ListMembershipsResponse( - resources=[], - next_page_token='def', + resources=[membership.Membership(),], next_page_token="ghi", ), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', - ), - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) pager = client.list_memberships(request={}) @@ -663,18 +679,14 @@ def test_list_memberships_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, membership.Membership) - for i in results) + assert all(isinstance(i, membership.Membership) for i in results) + def test_list_memberships_pages(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), - '__call__') as call: + with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( membership.ListMembershipsResponse( @@ -683,40 +695,30 @@ def test_list_memberships_pages(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', + next_page_token="abc", ), + membership.ListMembershipsResponse(resources=[], next_page_token="def",), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', + resources=[membership.Membership(),], next_page_token="ghi", ), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) pages = list(client.list_memberships(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token + @pytest.mark.asyncio async def test_list_memberships_async_pager(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( membership.ListMembershipsResponse( @@ -725,46 +727,35 @@ async def test_list_memberships_async_pager(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', + next_page_token="abc", ), + membership.ListMembershipsResponse(resources=[], next_page_token="def",), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', + resources=[membership.Membership(),], next_page_token="ghi", ), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) async_pager = await client.list_memberships(request={},) - assert async_pager.next_page_token == 'abc' + assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, membership.Membership) - for i in responses) + assert all(isinstance(i, membership.Membership) for i in responses) + @pytest.mark.asyncio async def test_list_memberships_async_pages(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_memberships), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( membership.ListMembershipsResponse( @@ -773,36 +764,29 @@ async def test_list_memberships_async_pages(): membership.Membership(), membership.Membership(), ], - next_page_token='abc', - ), - membership.ListMembershipsResponse( - resources=[], - next_page_token='def', + next_page_token="abc", ), + membership.ListMembershipsResponse(resources=[], next_page_token="def",), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - ], - next_page_token='ghi', + resources=[membership.Membership(),], next_page_token="ghi", ), membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - ], + resources=[membership.Membership(), membership.Membership(),], ), RuntimeError, ) pages = [] async for page_ in (await client.list_memberships(request={})).pages: pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_membership(transport: str = 'grpc', request_type=membership.GetMembershipRequest): + +def test_get_membership( + transport: str = "grpc", request_type=membership.GetMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -810,17 +794,17 @@ def test_get_membership(transport: str = 'grpc', request_type=membership.GetMemb request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', + name="name_value", + description="description_value", + external_id="external_id_value", + unique_id="unique_id_value", infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - endpoint=membership.MembershipEndpoint(gke_cluster=membership.GkeCluster(resource_link='resource_link_value')), + endpoint=membership.MembershipEndpoint( + gke_cluster=membership.GkeCluster(resource_link="resource_link_value") + ), ) response = client.get_membership(request) @@ -831,11 +815,13 @@ def test_get_membership(transport: str = 'grpc', request_type=membership.GetMemb # Establish that the response is the type that we expect. assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' - assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + assert response.name == "name_value" + assert response.description == "description_value" + assert response.external_id == "external_id_value" + assert response.unique_id == "unique_id_value" + assert ( + response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + ) def test_get_membership_from_dict(): @@ -846,14 +832,11 @@ def test_get_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: client.get_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -861,10 +844,11 @@ def test_get_membership_empty_call(): @pytest.mark.asyncio -async def test_get_membership_async(transport: str = 'grpc_asyncio', request_type=membership.GetMembershipRequest): +async def test_get_membership_async( + transport: str = "grpc_asyncio", request_type=membership.GetMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -872,17 +856,17 @@ async def test_get_membership_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership( - name='name_value', - description='description_value', - external_id='external_id_value', - unique_id='unique_id_value', - infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership( + name="name_value", + description="description_value", + external_id="external_id_value", + unique_id="unique_id_value", + infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, + ) + ) response = await client.get_membership(request) # Establish that the underlying gRPC stub method was called. @@ -892,11 +876,13 @@ async def test_get_membership_async(transport: str = 'grpc_asyncio', request_typ # Establish that the response is the type that we expect. assert isinstance(response, membership.Membership) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.external_id == 'external_id_value' - assert response.unique_id == 'unique_id_value' - assert response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + assert response.name == "name_value" + assert response.description == "description_value" + assert response.external_id == "external_id_value" + assert response.unique_id == "unique_id_value" + assert ( + response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM + ) @pytest.mark.asyncio @@ -905,20 +891,16 @@ async def test_get_membership_async_from_dict(): def test_get_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.GetMembershipRequest() - 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_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: call.return_value = membership.Membership() client.get_membership(request) @@ -929,29 +911,24 @@ def test_get_membership_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 async def test_get_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.GetMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership() + ) await client.get_membership(request) # Establish that the underlying gRPC stub method was called. @@ -961,96 +938,78 @@ async def test_get_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_get_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_membership( - name='name_value', - ) + client.get_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_get_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( - membership.GetMembershipRequest(), - name='name_value', + membership.GetMembershipRequest(), name="name_value", ) @pytest.mark.asyncio async def test_get_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_membership), - '__call__') as call: + with mock.patch.object(type(client.transport.get_membership), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.Membership() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.Membership()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.Membership() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_membership( - name='name_value', - ) + response = await client.get_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( - membership.GetMembershipRequest(), - name='name_value', + membership.GetMembershipRequest(), name="name_value", ) -def test_create_membership(transport: str = 'grpc', request_type=membership.CreateMembershipRequest): +def test_create_membership( + transport: str = "grpc", request_type=membership.CreateMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1059,10 +1018,10 @@ def test_create_membership(transport: str = 'grpc', request_type=membership.Crea # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1082,14 +1041,13 @@ def test_create_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: client.create_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1097,10 +1055,11 @@ def test_create_membership_empty_call(): @pytest.mark.asyncio -async def test_create_membership_async(transport: str = 'grpc_asyncio', request_type=membership.CreateMembershipRequest): +async def test_create_membership_async( + transport: str = "grpc_asyncio", request_type=membership.CreateMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1109,11 +1068,11 @@ async def test_create_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.create_membership(request) @@ -1132,21 +1091,19 @@ async def test_create_membership_async_from_dict(): def test_create_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.CreateMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.create_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1156,29 +1113,26 @@ def test_create_membership_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 async def test_create_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.CreateMembershipRequest() - 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_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.create_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.create_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1188,110 +1142,100 @@ async def test_create_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_membership( - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership(name="name_value"), + membership_id="membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].membership_id == 'membership_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == membership.Membership(name="name_value") + assert args[0].membership_id == "membership_id_value" def test_create_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( membership.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership(name="name_value"), + membership_id="membership_id_value", ) @pytest.mark.asyncio async def test_create_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_membership), - '__call__') as call: + type(client.transport.create_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_membership( - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership(name="name_value"), + membership_id="membership_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].membership_id == 'membership_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == membership.Membership(name="name_value") + assert args[0].membership_id == "membership_id_value" @pytest.mark.asyncio async def test_create_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( membership.CreateMembershipRequest(), - parent='parent_value', - resource=membership.Membership(name='name_value'), - membership_id='membership_id_value', + parent="parent_value", + resource=membership.Membership(name="name_value"), + membership_id="membership_id_value", ) -def test_delete_membership(transport: str = 'grpc', request_type=membership.DeleteMembershipRequest): +def test_delete_membership( + transport: str = "grpc", request_type=membership.DeleteMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1300,10 +1244,10 @@ def test_delete_membership(transport: str = 'grpc', request_type=membership.Dele # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1323,14 +1267,13 @@ def test_delete_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: client.delete_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1338,10 +1281,11 @@ def test_delete_membership_empty_call(): @pytest.mark.asyncio -async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_type=membership.DeleteMembershipRequest): +async def test_delete_membership_async( + transport: str = "grpc_asyncio", request_type=membership.DeleteMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1350,11 +1294,11 @@ async def test_delete_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.delete_membership(request) @@ -1373,21 +1317,19 @@ async def test_delete_membership_async_from_dict(): def test_delete_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.DeleteMembershipRequest() - 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.delete_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.delete_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1397,29 +1339,26 @@ def test_delete_membership_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 async def test_delete_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.DeleteMembershipRequest() - 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.delete_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.delete_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.delete_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1429,98 +1368,82 @@ async def test_delete_membership_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_delete_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_membership( - name='name_value', - ) + client.delete_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_delete_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( - membership.DeleteMembershipRequest(), - name='name_value', + membership.DeleteMembershipRequest(), name="name_value", ) @pytest.mark.asyncio async def test_delete_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_membership), - '__call__') as call: + type(client.transport.delete_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_membership( - name='name_value', - ) + response = await client.delete_membership(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( - membership.DeleteMembershipRequest(), - name='name_value', + membership.DeleteMembershipRequest(), name="name_value", ) -def test_update_membership(transport: str = 'grpc', request_type=membership.UpdateMembershipRequest): +def test_update_membership( + transport: str = "grpc", request_type=membership.UpdateMembershipRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1529,10 +1452,10 @@ def test_update_membership(transport: str = 'grpc', request_type=membership.Upda # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1552,14 +1475,13 @@ def test_update_membership_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: client.update_membership() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1567,10 +1489,11 @@ def test_update_membership_empty_call(): @pytest.mark.asyncio -async def test_update_membership_async(transport: str = 'grpc_asyncio', request_type=membership.UpdateMembershipRequest): +async def test_update_membership_async( + transport: str = "grpc_asyncio", request_type=membership.UpdateMembershipRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1579,11 +1502,11 @@ async def test_update_membership_async(transport: str = 'grpc_asyncio', request_ # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.update_membership(request) @@ -1602,21 +1525,19 @@ async def test_update_membership_async_from_dict(): def test_update_membership_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.UpdateMembershipRequest() - 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.update_membership), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + type(client.transport.update_membership), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1626,29 +1547,26 @@ def test_update_membership_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 async def test_update_membership_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.UpdateMembershipRequest() - 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.update_membership), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + type(client.transport.update_membership), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.update_membership(request) # Establish that the underlying gRPC stub method was called. @@ -1658,110 +1576,100 @@ async def test_update_membership_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_update_membership_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_membership( - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership(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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == membership.Membership(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_membership_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_membership( membership.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_membership_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_membership), - '__call__') as call: + type(client.transport.update_membership), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_membership( - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership(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] - assert args[0].name == 'name_value' - assert args[0].resource == membership.Membership(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == membership.Membership(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_membership_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_membership( membership.UpdateMembershipRequest(), - name='name_value', - resource=membership.Membership(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=membership.Membership(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_generate_connect_manifest(transport: str = 'grpc', request_type=membership.GenerateConnectManifestRequest): +def test_generate_connect_manifest( + transport: str = "grpc", request_type=membership.GenerateConnectManifestRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1770,11 +1678,10 @@ def test_generate_connect_manifest(transport: str = 'grpc', request_type=members # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = membership.GenerateConnectManifestResponse( - ) + call.return_value = membership.GenerateConnectManifestResponse() response = client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -1794,14 +1701,13 @@ def test_generate_connect_manifest_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: client.generate_connect_manifest() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1809,10 +1715,12 @@ def test_generate_connect_manifest_empty_call(): @pytest.mark.asyncio -async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', request_type=membership.GenerateConnectManifestRequest): +async def test_generate_connect_manifest_async( + transport: str = "grpc_asyncio", + request_type=membership.GenerateConnectManifestRequest, +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1821,11 +1729,12 @@ async def test_generate_connect_manifest_async(transport: str = 'grpc_asyncio', # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse( - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.GenerateConnectManifestResponse() + ) response = await client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -1843,20 +1752,18 @@ async def test_generate_connect_manifest_async_from_dict(): def test_generate_connect_manifest_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.GenerateConnectManifestRequest() - 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.generate_connect_manifest), - '__call__') as call: + type(client.transport.generate_connect_manifest), "__call__" + ) as call: call.return_value = membership.GenerateConnectManifestResponse() client.generate_connect_manifest(request) @@ -1867,29 +1774,26 @@ def test_generate_connect_manifest_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 async def test_generate_connect_manifest_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.GenerateConnectManifestRequest() - 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.generate_connect_manifest), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.GenerateConnectManifestResponse()) + type(client.transport.generate_connect_manifest), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.GenerateConnectManifestResponse() + ) await client.generate_connect_manifest(request) # Establish that the underlying gRPC stub method was called. @@ -1899,16 +1803,14 @@ async def test_generate_connect_manifest_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_initialize_hub(transport: str = 'grpc', request_type=membership.InitializeHubRequest): +def test_initialize_hub( + transport: str = "grpc", request_type=membership.InitializeHubRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1916,13 +1818,11 @@ def test_initialize_hub(transport: str = 'grpc', request_type=membership.Initial request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.initialize_hub), - '__call__') as call: + with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = membership.InitializeHubResponse( - service_identity='service_identity_value', - workload_identity_pool='workload_identity_pool_value', + service_identity="service_identity_value", + workload_identity_pool="workload_identity_pool_value", ) response = client.initialize_hub(request) @@ -1933,8 +1833,8 @@ def test_initialize_hub(transport: str = 'grpc', request_type=membership.Initial # Establish that the response is the type that we expect. assert isinstance(response, membership.InitializeHubResponse) - assert response.service_identity == 'service_identity_value' - assert response.workload_identity_pool == 'workload_identity_pool_value' + assert response.service_identity == "service_identity_value" + assert response.workload_identity_pool == "workload_identity_pool_value" def test_initialize_hub_from_dict(): @@ -1945,14 +1845,11 @@ def test_initialize_hub_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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.initialize_hub), - '__call__') as call: + with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: client.initialize_hub() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1960,10 +1857,11 @@ def test_initialize_hub_empty_call(): @pytest.mark.asyncio -async def test_initialize_hub_async(transport: str = 'grpc_asyncio', request_type=membership.InitializeHubRequest): +async def test_initialize_hub_async( + transport: str = "grpc_asyncio", request_type=membership.InitializeHubRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1971,14 +1869,14 @@ async def test_initialize_hub_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.initialize_hub), - '__call__') as call: + with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(membership.InitializeHubResponse( - service_identity='service_identity_value', - workload_identity_pool='workload_identity_pool_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.InitializeHubResponse( + service_identity="service_identity_value", + workload_identity_pool="workload_identity_pool_value", + ) + ) response = await client.initialize_hub(request) # Establish that the underlying gRPC stub method was called. @@ -1988,8 +1886,8 @@ async def test_initialize_hub_async(transport: str = 'grpc_asyncio', request_typ # Establish that the response is the type that we expect. assert isinstance(response, membership.InitializeHubResponse) - assert response.service_identity == 'service_identity_value' - assert response.workload_identity_pool == 'workload_identity_pool_value' + assert response.service_identity == "service_identity_value" + assert response.workload_identity_pool == "workload_identity_pool_value" @pytest.mark.asyncio @@ -1998,20 +1896,16 @@ async def test_initialize_hub_async_from_dict(): def test_initialize_hub_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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 = membership.InitializeHubRequest() - request.project = 'project/value' + request.project = "project/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.initialize_hub), - '__call__') as call: + with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: call.return_value = membership.InitializeHubResponse() client.initialize_hub(request) @@ -2022,29 +1916,24 @@ def test_initialize_hub_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project=project/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] @pytest.mark.asyncio async def test_initialize_hub_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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 = membership.InitializeHubRequest() - request.project = 'project/value' + request.project = "project/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.initialize_hub), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(membership.InitializeHubResponse()) + with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + membership.InitializeHubResponse() + ) await client.initialize_hub(request) # Establish that the underlying gRPC stub method was called. @@ -2054,10 +1943,7 @@ async def test_initialize_hub_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project=project/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] def test_credentials_transport_error(): @@ -2067,8 +1953,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - 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. @@ -2087,8 +1972,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + client_options={"scopes": ["1", "2"]}, transport=transport, ) @@ -2100,6 +1984,7 @@ def test_transport_instance(): client = GkeHubClient(transport=transport) assert client.transport is transport + def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.GkeHubGrpcTransport( @@ -2114,39 +1999,39 @@ def test_transport_get_channel(): channel = transport.grpc_channel assert channel -@pytest.mark.parametrize("transport_class", [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, -]) + +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], +) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.GkeHubGrpcTransport, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.GkeHubGrpcTransport,) + def test_gke_hub_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" + credentials_file="credentials.json", ) def test_gke_hub_base_transport(): # Instantiate the base transport. - with mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + with mock.patch( + "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport.__init__" + ) as Transport: Transport.return_value = None transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2155,13 +2040,13 @@ def test_gke_hub_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. methods = ( - 'list_memberships', - 'get_membership', - 'create_membership', - 'delete_membership', - 'update_membership', - 'generate_connect_manifest', - 'initialize_hub', + "list_memberships", + "get_membership", + "create_membership", + "delete_membership", + "update_membership", + "generate_connect_manifest", + "initialize_hub", ) for method in methods: with pytest.raises(NotImplementedError): @@ -2176,18 +2061,20 @@ def test_gke_hub_base_transport(): @requires_google_auth_gte_1_25_0 def test_gke_hub_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('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", + load_creds.assert_called_once_with( + "credentials.json", scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -2195,23 +2082,28 @@ def test_gke_hub_base_transport_with_credentials_file(): @requires_google_auth_lt_1_25_0 def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): # 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('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_gke_hub_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport() @@ -2221,14 +2113,12 @@ def test_gke_hub_base_transport_with_adc(): @requires_google_auth_gte_1_25_0 def test_gke_hub_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @@ -2236,42 +2126,36 @@ def test_gke_hub_auth_adc(): @requires_google_auth_lt_1_25_0 def test_gke_hub_auth_adc_old_google_auth(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_gte_1_25_0 def test_gke_hub_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_lt_1_25_0 def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): @@ -2280,9 +2164,8 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -2291,30 +2174,27 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): "transport_class,grpc_helpers", [ (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), ], ) def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( grpc_helpers, "create_channel", autospec=True ) as create_channel: creds = ga_credentials.AnonymousCredentials() adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) create_channel.assert_called_with( "gkehub.googleapis.com:443", credentials=creds, credentials_file=None, quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), scopes=["1", "2"], default_host="gkehub.googleapis.com", ssl_credentials=None, @@ -2325,10 +2205,11 @@ def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. @@ -2337,7 +2218,7 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( transport_class( host="squid.clam.whelk", credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds + ssl_channel_credentials=mock_ssl_channel_creds, ) mock_create_channel.assert_called_once_with( "squid.clam.whelk:443", @@ -2358,37 +2239,40 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: transport_class( credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback + client_cert_source_for_mtls=client_cert_source_callback, ) expected_cert, expected_key = client_cert_source_callback() mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key + certificate_chain=expected_cert, private_key=expected_key ) def test_gke_hub_host_no_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_host_with_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com:8000" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:8000' + assert client.transport._host == "gkehub.googleapis.com:8000" + def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2396,12 +2280,11 @@ def test_gke_hub_grpc_transport_channel(): def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2410,12 +2293,17 @@ def test_gke_hub_grpc_asyncio_transport_channel(): # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -2424,7 +2312,7 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2454,17 +2342,20 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_adc( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_adc(transport_class): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() @@ -2494,16 +2385,12 @@ def test_gke_hub_transport_channel_mtls_with_adc( def test_gke_hub_grpc_lro_client(): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2511,16 +2398,12 @@ def test_gke_hub_grpc_lro_client(): def test_gke_hub_grpc_lro_async_client(): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2530,7 +2413,9 @@ def test_membership_path(): project = "squid" location = "clam" membership = "whelk" - expected = "projects/{project}/locations/{location}/memberships/{membership}".format(project=project, location=location, membership=membership, ) + expected = "projects/{project}/locations/{location}/memberships/{membership}".format( + project=project, location=location, membership=membership, + ) actual = GkeHubClient.membership_path(project, location, membership) assert expected == actual @@ -2547,9 +2432,12 @@ def test_parse_membership_path(): actual = GkeHubClient.parse_membership_path(path) assert expected == actual + def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) actual = GkeHubClient.common_billing_account_path(billing_account) assert expected == actual @@ -2564,9 +2452,10 @@ def test_parse_common_billing_account_path(): actual = GkeHubClient.parse_common_billing_account_path(path) assert expected == actual + def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) + expected = "folders/{folder}".format(folder=folder,) actual = GkeHubClient.common_folder_path(folder) assert expected == actual @@ -2581,9 +2470,10 @@ def test_parse_common_folder_path(): actual = GkeHubClient.parse_common_folder_path(path) assert expected == actual + def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) + expected = "organizations/{organization}".format(organization=organization,) actual = GkeHubClient.common_organization_path(organization) assert expected == actual @@ -2598,9 +2488,10 @@ def test_parse_common_organization_path(): actual = GkeHubClient.parse_common_organization_path(path) assert expected == actual + def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project, ) + expected = "projects/{project}".format(project=project,) actual = GkeHubClient.common_project_path(project) assert expected == actual @@ -2615,10 +2506,13 @@ def test_parse_common_project_path(): actual = GkeHubClient.parse_common_project_path(path) assert expected == actual + def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) actual = GkeHubClient.common_location_path(project, location) assert expected == actual @@ -2638,17 +2532,19 @@ def test_parse_common_location_path(): def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: transport_class = GkeHubClient.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) diff --git a/tests/unit/gapic/gkehub_v1beta/__init__.py b/tests/unit/gapic/gkehub_v1beta/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/gkehub_v1beta/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py b/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py similarity index 66% rename from owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py rename to tests/unit/gapic/gkehub_v1beta/test_gke_hub.py index 25d6d66..3ea9bc7 100644 --- a/owl-bot-staging/v1beta/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py +++ b/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py @@ -41,7 +41,9 @@ from google.cloud.gkehub_v1beta.services.gke_hub import GkeHubClient from google.cloud.gkehub_v1beta.services.gke_hub import pagers from google.cloud.gkehub_v1beta.services.gke_hub import transports -from google.cloud.gkehub_v1beta.services.gke_hub.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.gkehub_v1beta.services.gke_hub.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.gkehub_v1beta.types import feature from google.cloud.gkehub_v1beta.types import service from google.longrunning import operations_pb2 @@ -64,6 +66,7 @@ reason="This test requires google-auth >= 1.25.0", ) + def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -72,7 +75,11 @@ def client_cert_source_callback(): # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) def test__get_default_mtls_endpoint(): @@ -84,46 +91,51 @@ def test__get_default_mtls_endpoint(): assert GkeHubClient._get_default_mtls_endpoint(None) is None assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ( + GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: factory.return_value = creds info = {"valid": True} client = client_class.from_service_account_info(info) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) use_jwt.assert_called_with(True) -@pytest.mark.parametrize("client_class", [ - GkeHubClient, - GkeHubAsyncClient, -]) +@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) def test_gke_hub_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + 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") assert client.transport._credentials == creds @@ -133,7 +145,7 @@ def test_gke_hub_client_from_service_account_file(client_class): assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_client_get_transport_class(): @@ -147,29 +159,34 @@ def test_gke_hub_client_get_transport_class(): assert transport == transports.GkeHubGrpcTransport -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) def test_gke_hub_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, 'get_transport_class') as gtc: + with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: client = client_class(transport=transport_name) gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -185,7 +202,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -201,7 +218,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -221,13 +238,15 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client = client_class() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): with pytest.raises(ValueError): client = client_class() # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -240,24 +259,48 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_ client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient)) -@mock.patch.object(GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient)) + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), + ( + GkeHubAsyncClient, + transports.GkeHubGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) +) +@mock.patch.object( + GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) +) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): +def test_gke_hub_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) @@ -280,10 +323,18 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): if use_client_cert_env == "false": expected_host = client.DEFAULT_ENDPOINT expected_client_cert_source = None @@ -304,9 +355,14 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): patched.return_value = None client = client_class() patched.assert_called_once_with( @@ -320,16 +376,19 @@ def test_gke_hub_client_mtls_env_auto(client_class, transport_class, transport_n ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_scopes(client_class, transport_class, transport_name): +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_scopes( + client_class, transport_class, transport_name +): # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: + 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) patched.assert_called_once_with( @@ -342,16 +401,20 @@ def test_gke_hub_client_client_options_scopes(client_class, transport_class, tra client_info=transports.base.DEFAULT_CLIENT_INFO, ) -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_gke_hub_client_client_options_credentials_file(client_class, transport_class, transport_name): + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), + (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_client_options_credentials_file( + client_class, transport_class, transport_name +): # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( @@ -366,11 +429,11 @@ def test_gke_hub_client_client_options_credentials_file(client_class, transport_ def test_gke_hub_client_client_options_from_dict(): - with mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubGrpcTransport.__init__') as grpc_transport: + with mock.patch( + "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubGrpcTransport.__init__" + ) as grpc_transport: grpc_transport.return_value = None - client = GkeHubClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) + client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) grpc_transport.assert_called_once_with( credentials=None, credentials_file=None, @@ -382,10 +445,11 @@ def test_gke_hub_client_client_options_from_dict(): ) -def test_list_features(transport: str = 'grpc', request_type=service.ListFeaturesRequest): +def test_list_features( + transport: str = "grpc", request_type=service.ListFeaturesRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -393,12 +457,10 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse( - next_page_token='next_page_token_value', + next_page_token="next_page_token_value", ) response = client.list_features(request) @@ -409,7 +471,7 @@ def test_list_features(transport: str = 'grpc', request_type=service.ListFeature # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" def test_list_features_from_dict(): @@ -420,14 +482,11 @@ def test_list_features_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: client.list_features() call.assert_called() _, args, _ = call.mock_calls[0] @@ -435,10 +494,11 @@ def test_list_features_empty_call(): @pytest.mark.asyncio -async def test_list_features_async(transport: str = 'grpc_asyncio', request_type=service.ListFeaturesRequest): +async def test_list_features_async( + transport: str = "grpc_asyncio", request_type=service.ListFeaturesRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -446,13 +506,11 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse( - next_page_token='next_page_token_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse(next_page_token="next_page_token_value",) + ) response = await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -462,7 +520,7 @@ async def test_list_features_async(transport: str = 'grpc_asyncio', request_type # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == 'next_page_token_value' + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio @@ -471,20 +529,16 @@ async def test_list_features_async_from_dict(): def test_list_features_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: call.return_value = service.ListFeaturesResponse() client.list_features(request) @@ -495,29 +549,24 @@ def test_list_features_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 async def test_list_features_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.ListFeaturesRequest() - 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_features), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + with mock.patch.object(type(client.transport.list_features), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -527,135 +576,97 @@ async def test_list_features_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_features_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_features( - parent='parent_value', - ) + client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" def test_list_features_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) @pytest.mark.asyncio async def test_list_features_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListFeaturesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListFeaturesResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.ListFeaturesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_features( - parent='parent_value', - ) + response = await client.list_features(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] - assert args[0].parent == 'parent_value' + assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_features_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_features( - service.ListFeaturesRequest(), - parent='parent_value', + service.ListFeaturesRequest(), parent="parent_value", ) def test_list_features_pager(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) pager = client.list_features(request={}) @@ -663,146 +674,100 @@ def test_list_features_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, feature.Feature) - for i in results) + assert all(isinstance(i, feature.Feature) for i in results) + def test_list_features_pages(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), - '__call__') as call: + with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = list(client.list_features(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token + @pytest.mark.asyncio async def test_list_features_async_pager(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', - ), - service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) async_pager = await client.list_features(request={},) - assert async_pager.next_page_token == 'abc' + assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, feature.Feature) - for i in responses) + assert all(isinstance(i, feature.Feature) for i in responses) + @pytest.mark.asyncio async def test_list_features_async_pages(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_features), - '__call__', new_callable=mock.AsyncMock) as call: + type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock + ) as call: # Set the response to a series of pages. call.side_effect = ( service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - feature.Feature(), - ], - next_page_token='abc', - ), - service.ListFeaturesResponse( - resources=[], - next_page_token='def', + resources=[feature.Feature(), feature.Feature(), feature.Feature(),], + next_page_token="abc", ), + service.ListFeaturesResponse(resources=[], next_page_token="def",), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - ], - next_page_token='ghi', + resources=[feature.Feature(),], next_page_token="ghi", ), service.ListFeaturesResponse( - resources=[ - feature.Feature(), - feature.Feature(), - ], + resources=[feature.Feature(), feature.Feature(),], ), RuntimeError, ) pages = [] async for page_ in (await client.list_features(request={})).pages: pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureRequest): + +def test_get_feature(transport: str = "grpc", request_type=service.GetFeatureRequest): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -810,13 +775,9 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = feature.Feature( - name='name_value', - ) + call.return_value = feature.Feature(name="name_value",) response = client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -826,7 +787,7 @@ def test_get_feature(transport: str = 'grpc', request_type=service.GetFeatureReq # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" def test_get_feature_from_dict(): @@ -837,14 +798,11 @@ def test_get_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: client.get_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -852,10 +810,11 @@ def test_get_feature_empty_call(): @pytest.mark.asyncio -async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=service.GetFeatureRequest): +async def test_get_feature_async( + transport: str = "grpc_asyncio", request_type=service.GetFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -863,13 +822,11 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature( - name='name_value', - )) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + feature.Feature(name="name_value",) + ) response = await client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -879,7 +836,7 @@ async def test_get_feature_async(transport: str = 'grpc_asyncio', request_type=s # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == 'name_value' + assert response.name == "name_value" @pytest.mark.asyncio @@ -888,20 +845,16 @@ async def test_get_feature_async_from_dict(): def test_get_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = feature.Feature() client.get_feature(request) @@ -912,28 +865,21 @@ def test_get_feature_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 async def test_get_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.GetFeatureRequest() - 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) await client.get_feature(request) @@ -944,96 +890,76 @@ async def test_get_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_get_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_feature( - name='name_value', - ) + client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_get_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_get_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_feature( - name='name_value', - ) + response = await client.get_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.GetFeatureRequest(), - name='name_value', + service.GetFeatureRequest(), name="name_value", ) -def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeatureRequest): +def test_create_feature( + transport: str = "grpc", request_type=service.CreateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1041,11 +967,9 @@ def test_create_feature(transport: str = 'grpc', request_type=service.CreateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1065,14 +989,11 @@ def test_create_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: client.create_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1080,10 +1001,11 @@ def test_create_feature_empty_call(): @pytest.mark.asyncio -async def test_create_feature_async(transport: str = 'grpc_asyncio', request_type=service.CreateFeatureRequest): +async def test_create_feature_async( + transport: str = "grpc_asyncio", request_type=service.CreateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1091,12 +1013,10 @@ async def test_create_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.create_feature(request) @@ -1115,21 +1035,17 @@ async def test_create_feature_async_from_dict(): def test_create_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1139,29 +1055,24 @@ def test_create_feature_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 async def test_create_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.CreateFeatureRequest() - 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_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1171,110 +1082,96 @@ async def test_create_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" def test_create_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) @pytest.mark.asyncio async def test_create_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_feature( - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_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] - assert args[0].parent == 'parent_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].feature_id == 'feature_id_value' + assert args[0].parent == "parent_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].feature_id == "feature_id_value" @pytest.mark.asyncio async def test_create_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.CreateFeatureRequest(), - parent='parent_value', - resource=feature.Feature(name='name_value'), - feature_id='feature_id_value', + parent="parent_value", + resource=feature.Feature(name="name_value"), + feature_id="feature_id_value", ) -def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeatureRequest): +def test_delete_feature( + transport: str = "grpc", request_type=service.DeleteFeatureRequest +): client = GkeHubClient( - 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,11 +1179,9 @@ def test_delete_feature(transport: str = 'grpc', request_type=service.DeleteFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1306,14 +1201,11 @@ def test_delete_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: client.delete_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1321,10 +1213,11 @@ def test_delete_feature_empty_call(): @pytest.mark.asyncio -async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_type=service.DeleteFeatureRequest): +async def test_delete_feature_async( + transport: str = "grpc_asyncio", request_type=service.DeleteFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1332,12 +1225,10 @@ async def test_delete_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.delete_feature(request) @@ -1356,21 +1247,17 @@ async def test_delete_feature_async_from_dict(): def test_delete_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1380,29 +1267,24 @@ def test_delete_feature_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 async def test_delete_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.DeleteFeatureRequest() - 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.delete_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1412,98 +1294,78 @@ async def test_delete_feature_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] def test_delete_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_feature( - name='name_value', - ) + client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" def test_delete_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) @pytest.mark.asyncio async def test_delete_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_feature( - name='name_value', - ) + response = await client.delete_feature(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' + assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( - service.DeleteFeatureRequest(), - name='name_value', + service.DeleteFeatureRequest(), name="name_value", ) -def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeatureRequest): +def test_update_feature( + transport: str = "grpc", request_type=service.UpdateFeatureRequest +): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1511,11 +1373,9 @@ def test_update_feature(transport: str = 'grpc', request_type=service.UpdateFeat request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') + call.return_value = operations_pb2.Operation(name="operations/spam") response = client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1535,14 +1395,11 @@ def test_update_feature_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + 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_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: client.update_feature() call.assert_called() _, args, _ = call.mock_calls[0] @@ -1550,10 +1407,11 @@ def test_update_feature_empty_call(): @pytest.mark.asyncio -async def test_update_feature_async(transport: str = 'grpc_asyncio', request_type=service.UpdateFeatureRequest): +async def test_update_feature_async( + transport: str = "grpc_asyncio", request_type=service.UpdateFeatureRequest +): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1561,12 +1419,10 @@ async def test_update_feature_async(transport: str = 'grpc_asyncio', request_typ request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) response = await client.update_feature(request) @@ -1585,21 +1441,17 @@ async def test_update_feature_async_from_dict(): def test_update_feature_field_headers(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1609,29 +1461,24 @@ def test_update_feature_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 async def test_update_feature_field_headers_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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.UpdateFeatureRequest() - 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.update_feature), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) await client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -1641,103 +1488,88 @@ async def test_update_feature_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_update_feature_flattened(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_feature_flattened_error(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_feature_flattened_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_feature), - '__call__') as call: + with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_feature( - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(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] - assert args[0].name == 'name_value' - assert args[0].resource == feature.Feature(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + assert args[0].name == "name_value" + assert args[0].resource == feature.Feature(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_feature_flattened_error_async(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) + client = GkeHubAsyncClient(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_feature( service.UpdateFeatureRequest(), - name='name_value', - resource=feature.Feature(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + name="name_value", + resource=feature.Feature(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1748,8 +1580,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - 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. @@ -1768,8 +1599,7 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + client_options={"scopes": ["1", "2"]}, transport=transport, ) @@ -1781,6 +1611,7 @@ def test_transport_instance(): client = GkeHubClient(transport=transport) assert client.transport is transport + def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.GkeHubGrpcTransport( @@ -1795,39 +1626,39 @@ def test_transport_get_channel(): channel = transport.grpc_channel assert channel -@pytest.mark.parametrize("transport_class", [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, -]) + +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], +) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.GkeHubGrpcTransport, - ) + client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.GkeHubGrpcTransport,) + def test_gke_hub_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" + credentials_file="credentials.json", ) def test_gke_hub_base_transport(): # Instantiate the base transport. - with mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport.__init__') as Transport: + with mock.patch( + "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport.__init__" + ) as Transport: Transport.return_value = None transport = transports.GkeHubTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1836,11 +1667,11 @@ def test_gke_hub_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. methods = ( - 'list_features', - 'get_feature', - 'create_feature', - 'delete_feature', - 'update_feature', + "list_features", + "get_feature", + "create_feature", + "delete_feature", + "update_feature", ) for method in methods: with pytest.raises(NotImplementedError): @@ -1855,18 +1686,20 @@ def test_gke_hub_base_transport(): @requires_google_auth_gte_1_25_0 def test_gke_hub_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('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", + load_creds.assert_called_once_with( + "credentials.json", scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -1874,23 +1707,28 @@ def test_gke_hub_base_transport_with_credentials_file(): @requires_google_auth_lt_1_25_0 def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): # 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('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + credentials_file="credentials.json", quota_project_id="octopus", ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_gke_hub_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages') as Transport: + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" + ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.GkeHubTransport() @@ -1900,14 +1738,12 @@ def test_gke_hub_base_transport_with_adc(): @requires_google_auth_gte_1_25_0 def test_gke_hub_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @@ -1915,42 +1751,36 @@ def test_gke_hub_auth_adc(): @requires_google_auth_lt_1_25_0 def test_gke_hub_auth_adc_old_google_auth(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) GkeHubClient() adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_gte_1_25_0 def test_gke_hub_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class", - [ - transports.GkeHubGrpcTransport, - transports.GkeHubGrpcAsyncIOTransport, - ], + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], ) @requires_google_auth_lt_1_25_0 def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): @@ -1959,9 +1789,8 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @@ -1970,30 +1799,27 @@ def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): "transport_class,grpc_helpers", [ (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async) + (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), ], ) def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( grpc_helpers, "create_channel", autospec=True ) as create_channel: creds = ga_credentials.AnonymousCredentials() adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) create_channel.assert_called_with( "gkehub.googleapis.com:443", credentials=creds, credentials_file=None, quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), scopes=["1", "2"], default_host="gkehub.googleapis.com", ssl_credentials=None, @@ -2004,10 +1830,11 @@ def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. @@ -2016,7 +1843,7 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( transport_class( host="squid.clam.whelk", credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds + ssl_channel_credentials=mock_ssl_channel_creds, ) mock_create_channel.assert_called_once_with( "squid.clam.whelk:443", @@ -2037,37 +1864,40 @@ def test_gke_hub_grpc_transport_client_cert_source_for_mtls( with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: transport_class( credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback + client_cert_source_for_mtls=client_cert_source_callback, ) expected_cert, expected_key = client_cert_source_callback() mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key + certificate_chain=expected_cert, private_key=expected_key ) def test_gke_hub_host_no_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:443' + assert client.transport._host == "gkehub.googleapis.com:443" def test_gke_hub_host_with_port(): client = GkeHubClient( credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='gkehub.googleapis.com:8000'), + client_options=client_options.ClientOptions( + api_endpoint="gkehub.googleapis.com:8000" + ), ) - assert client.transport._host == 'gkehub.googleapis.com:8000' + assert client.transport._host == "gkehub.googleapis.com:8000" + def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2075,12 +1905,11 @@ def test_gke_hub_grpc_transport_channel(): def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2089,12 +1918,17 @@ def test_gke_hub_grpc_asyncio_transport_channel(): # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -2103,7 +1937,7 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2133,17 +1967,20 @@ def test_gke_hub_transport_channel_mtls_with_client_cert_source( # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport]) -def test_gke_hub_transport_channel_mtls_with_adc( - transport_class -): +@pytest.mark.parametrize( + "transport_class", + [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], +) +def test_gke_hub_transport_channel_mtls_with_adc(transport_class): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() @@ -2173,16 +2010,12 @@ def test_gke_hub_transport_channel_mtls_with_adc( def test_gke_hub_grpc_lro_client(): client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2190,16 +2023,12 @@ def test_gke_hub_grpc_lro_client(): def test_gke_hub_grpc_lro_async_client(): client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) + assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2209,7 +2038,9 @@ def test_feature_path(): project = "squid" location = "clam" feature = "whelk" - expected = "projects/{project}/locations/{location}/features/{feature}".format(project=project, location=location, feature=feature, ) + expected = "projects/{project}/locations/{location}/features/{feature}".format( + project=project, location=location, feature=feature, + ) actual = GkeHubClient.feature_path(project, location, feature) assert expected == actual @@ -2226,9 +2057,12 @@ def test_parse_feature_path(): actual = GkeHubClient.parse_feature_path(path) assert expected == actual + def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) actual = GkeHubClient.common_billing_account_path(billing_account) assert expected == actual @@ -2243,9 +2077,10 @@ def test_parse_common_billing_account_path(): actual = GkeHubClient.parse_common_billing_account_path(path) assert expected == actual + def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) + expected = "folders/{folder}".format(folder=folder,) actual = GkeHubClient.common_folder_path(folder) assert expected == actual @@ -2260,9 +2095,10 @@ def test_parse_common_folder_path(): actual = GkeHubClient.parse_common_folder_path(path) assert expected == actual + def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) + expected = "organizations/{organization}".format(organization=organization,) actual = GkeHubClient.common_organization_path(organization) assert expected == actual @@ -2277,9 +2113,10 @@ def test_parse_common_organization_path(): actual = GkeHubClient.parse_common_organization_path(path) assert expected == actual + def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project, ) + expected = "projects/{project}".format(project=project,) actual = GkeHubClient.common_project_path(project) assert expected == actual @@ -2294,10 +2131,13 @@ def test_parse_common_project_path(): actual = GkeHubClient.parse_common_project_path(path) assert expected == actual + def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) actual = GkeHubClient.common_location_path(project, location) assert expected == actual @@ -2317,17 +2157,19 @@ def test_parse_common_location_path(): def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) - with mock.patch.object(transports.GkeHubTransport, '_prep_wrapped_messages') as prep: + with mock.patch.object( + transports.GkeHubTransport, "_prep_wrapped_messages" + ) as prep: transport_class = GkeHubClient.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) diff --git a/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py b/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py index f6b3ec4..e6e73db 100644 --- a/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py +++ b/tests/unit/gapic/gkehub_v1beta1/test_gke_hub_membership_service.py @@ -2538,7 +2538,7 @@ def test_gke_hub_membership_service_grpc_transport_client_cert_source_for_mtls( "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -2647,7 +2647,7 @@ def test_gke_hub_membership_service_transport_channel_mtls_with_client_cert_sour "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -2694,7 +2694,7 @@ def test_gke_hub_membership_service_transport_channel_mtls_with_adc(transport_cl "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ diff --git a/tests/unit/gapic/metering_v1alpha/__init__.py b/tests/unit/gapic/metering_v1alpha/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/metering_v1alpha/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/tests/unit/gapic/metering_v1beta/__init__.py b/tests/unit/gapic/metering_v1beta/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/metering_v1beta/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/tests/unit/gapic/multiclusteringress_v1/__init__.py b/tests/unit/gapic/multiclusteringress_v1/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/multiclusteringress_v1/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py b/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/tests/unit/gapic/multiclusteringress_v1beta/__init__.py b/tests/unit/gapic/multiclusteringress_v1beta/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/multiclusteringress_v1beta/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# diff --git a/tests/unit/gapic/servicemesh_v1alpha/__init__.py b/tests/unit/gapic/servicemesh_v1alpha/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/servicemesh_v1alpha/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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 7ce005163401231e770e90ff783b36abddc6010c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 10:44:55 +0000 Subject: [PATCH 3/8] exclude v1alpha, v1alpha2 and v1beta --- .github/.OwlBot.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index 50bf7a0..c902419 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -18,6 +18,11 @@ docker: deep-remove-regex: - /owl-bot-staging +deep-preserve-regex: + - /owl-bot-staging/v1alpha + - /owl-bot-staging/v1alpha2 + - /owl-bot-staging/v1beta + deep-copy-regex: - source: /google/cloud/gkehub/(v.*)/.*-py/(.*) dest: /owl-bot-staging/$1/$2 From c5c1220fbfac522b72756de47ee28c5da6a9bfca Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 10:48:28 +0000 Subject: [PATCH 4/8] remove v1alpha --- docs/cloudauditlogging_v1alpha/services.rst | 4 - docs/cloudauditlogging_v1alpha/types.rst | 7 - docs/configmanagement_v1alpha/services.rst | 4 - docs/configmanagement_v1alpha/types.rst | 7 - docs/gkehub_v1alpha/gke_hub.rst | 10 - docs/gkehub_v1alpha/services.rst | 6 - docs/gkehub_v1alpha/types.rst | 7 - docs/gkehub_v1alpha2/gke_hub.rst | 10 - docs/gkehub_v1alpha2/services.rst | 6 - docs/gkehub_v1alpha2/types.rst | 7 - docs/metering_v1alpha/services.rst | 4 - docs/metering_v1alpha/types.rst | 7 - docs/multiclusteringress_v1alpha/services.rst | 4 - docs/multiclusteringress_v1alpha/types.rst | 7 - docs/servicemesh_v1alpha/services.rst | 4 - docs/servicemesh_v1alpha/types.rst | 7 - .../gkehub/cloudauditlogging/__init__.py | 22 - .../cloud/gkehub/cloudauditlogging/py.typed | 2 - .../cloudauditlogging_v1alpha/__init__.py | 20 - .../gapic_metadata.json | 7 - .../gkehub/cloudauditlogging_v1alpha/py.typed | 2 - .../services/__init__.py | 15 - .../types/__init__.py | 18 - .../types/cloudauditlogging.py | 41 - .../configmanagement_v1alpha/__init__.py | 70 - .../gapic_metadata.json | 7 - .../gkehub/configmanagement_v1alpha/py.typed | 2 - .../services/__init__.py | 15 - .../types/__init__.py | 70 - .../types/configmanagement.py | 583 ---- .../cloud/gkehub/metering_v1alpha/__init__.py | 20 - .../metering_v1alpha/gapic_metadata.json | 7 - google/cloud/gkehub/metering_v1alpha/py.typed | 2 - .../metering_v1alpha/services/__init__.py | 15 - .../gkehub/metering_v1alpha/types/__init__.py | 18 - .../gkehub/metering_v1alpha/types/metering.py | 44 - .../multiclusteringress_v1alpha/__init__.py | 24 - .../gapic_metadata.json | 7 - .../multiclusteringress_v1alpha/py.typed | 2 - .../services/__init__.py | 15 - .../types/__init__.py | 24 - .../types/multiclusteringress.py | 51 - google/cloud/gkehub/servicemesh/__init__.py | 30 - google/cloud/gkehub/servicemesh/py.typed | 2 - .../gkehub/servicemesh_v1alpha/__init__.py | 28 - .../servicemesh_v1alpha/gapic_metadata.json | 7 - .../cloud/gkehub/servicemesh_v1alpha/py.typed | 2 - .../servicemesh_v1alpha/services/__init__.py | 15 - .../servicemesh_v1alpha/types/__init__.py | 28 - .../servicemesh_v1alpha/types/servicemesh.py | 145 - google/cloud/gkehub_v1alpha/__init__.py | 52 - .../cloud/gkehub_v1alpha/gapic_metadata.json | 73 - google/cloud/gkehub_v1alpha/py.typed | 2 - .../cloud/gkehub_v1alpha/services/__init__.py | 15 - .../services/gke_hub/__init__.py | 22 - .../services/gke_hub/async_client.py | 634 ---- .../gkehub_v1alpha/services/gke_hub/client.py | 827 ------ .../gkehub_v1alpha/services/gke_hub/pagers.py | 156 - .../services/gke_hub/transports/__init__.py | 33 - .../services/gke_hub/transports/base.py | 225 -- .../services/gke_hub/transports/grpc.py | 385 --- .../gke_hub/transports/grpc_asyncio.py | 394 --- google/cloud/gkehub_v1alpha/types/__init__.py | 50 - google/cloud/gkehub_v1alpha/types/feature.py | 275 -- google/cloud/gkehub_v1alpha/types/service.py | 269 -- google/cloud/gkehub_v1alpha2/__init__.py | 68 - .../cloud/gkehub_v1alpha2/gapic_metadata.json | 93 - google/cloud/gkehub_v1alpha2/py.typed | 2 - .../gkehub_v1alpha2/services/__init__.py | 15 - .../services/gke_hub/__init__.py | 22 - .../services/gke_hub/async_client.py | 740 ----- .../services/gke_hub/client.py | 937 ------ .../services/gke_hub/pagers.py | 155 - .../services/gke_hub/transports/__init__.py | 33 - .../services/gke_hub/transports/base.py | 260 -- .../services/gke_hub/transports/grpc.py | 442 --- .../gke_hub/transports/grpc_asyncio.py | 456 --- .../cloud/gkehub_v1alpha2/types/__init__.py | 64 - .../cloud/gkehub_v1alpha2/types/membership.py | 724 ----- ...ixup_cloudauditlogging_v1alpha_keywords.py | 175 -- ...fixup_configmanagement_v1alpha_keywords.py | 175 -- scripts/fixup_gkehub_v1alpha2_keywords.py | 182 -- scripts/fixup_gkehub_v1alpha_keywords.py | 180 -- scripts/fixup_metering_v1alpha_keywords.py | 175 -- ...up_multiclusteringress_v1alpha_keywords.py | 175 -- scripts/fixup_servicemesh_v1alpha_keywords.py | 175 -- .../cloudauditlogging_v1alpha/__init__.py | 15 - .../configmanagement_v1alpha/__init__.py | 15 - tests/unit/gapic/gkehub_v1alpha/__init__.py | 15 - .../unit/gapic/gkehub_v1alpha/test_gke_hub.py | 2178 -------------- tests/unit/gapic/gkehub_v1alpha2/__init__.py | 15 - .../gapic/gkehub_v1alpha2/test_gke_hub.py | 2550 ----------------- tests/unit/gapic/metering_v1alpha/__init__.py | 15 - .../multiclusteringress_v1alpha/__init__.py | 15 - .../gapic/servicemesh_v1alpha/__init__.py | 15 - 95 files changed, 14954 deletions(-) delete mode 100644 docs/cloudauditlogging_v1alpha/services.rst delete mode 100644 docs/cloudauditlogging_v1alpha/types.rst delete mode 100644 docs/configmanagement_v1alpha/services.rst delete mode 100644 docs/configmanagement_v1alpha/types.rst delete mode 100644 docs/gkehub_v1alpha/gke_hub.rst delete mode 100644 docs/gkehub_v1alpha/services.rst delete mode 100644 docs/gkehub_v1alpha/types.rst delete mode 100644 docs/gkehub_v1alpha2/gke_hub.rst delete mode 100644 docs/gkehub_v1alpha2/services.rst delete mode 100644 docs/gkehub_v1alpha2/types.rst delete mode 100644 docs/metering_v1alpha/services.rst delete mode 100644 docs/metering_v1alpha/types.rst delete mode 100644 docs/multiclusteringress_v1alpha/services.rst delete mode 100644 docs/multiclusteringress_v1alpha/types.rst delete mode 100644 docs/servicemesh_v1alpha/services.rst delete mode 100644 docs/servicemesh_v1alpha/types.rst delete mode 100644 google/cloud/gkehub/cloudauditlogging/__init__.py delete mode 100644 google/cloud/gkehub/cloudauditlogging/py.typed delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/py.typed delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py delete mode 100644 google/cloud/gkehub/metering_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub/metering_v1alpha/py.typed delete mode 100644 google/cloud/gkehub/metering_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1alpha/types/metering.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/py.typed delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py delete mode 100644 google/cloud/gkehub/servicemesh/__init__.py delete mode 100644 google/cloud/gkehub/servicemesh/py.typed delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/py.typed delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py delete mode 100644 google/cloud/gkehub_v1alpha/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha/gapic_metadata.json delete mode 100644 google/cloud/gkehub_v1alpha/py.typed delete mode 100644 google/cloud/gkehub_v1alpha/services/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/client.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py delete mode 100644 google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py delete mode 100644 google/cloud/gkehub_v1alpha/types/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha/types/feature.py delete mode 100644 google/cloud/gkehub_v1alpha/types/service.py delete mode 100644 google/cloud/gkehub_v1alpha2/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha2/gapic_metadata.json delete mode 100644 google/cloud/gkehub_v1alpha2/py.typed delete mode 100644 google/cloud/gkehub_v1alpha2/services/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/client.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py delete mode 100644 google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py delete mode 100644 google/cloud/gkehub_v1alpha2/types/__init__.py delete mode 100644 google/cloud/gkehub_v1alpha2/types/membership.py delete mode 100644 scripts/fixup_cloudauditlogging_v1alpha_keywords.py delete mode 100644 scripts/fixup_configmanagement_v1alpha_keywords.py delete mode 100644 scripts/fixup_gkehub_v1alpha2_keywords.py delete mode 100644 scripts/fixup_gkehub_v1alpha_keywords.py delete mode 100644 scripts/fixup_metering_v1alpha_keywords.py delete mode 100644 scripts/fixup_multiclusteringress_v1alpha_keywords.py delete mode 100644 scripts/fixup_servicemesh_v1alpha_keywords.py delete mode 100644 tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py delete mode 100644 tests/unit/gapic/configmanagement_v1alpha/__init__.py delete mode 100644 tests/unit/gapic/gkehub_v1alpha/__init__.py delete mode 100644 tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py delete mode 100644 tests/unit/gapic/gkehub_v1alpha2/__init__.py delete mode 100644 tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py delete mode 100644 tests/unit/gapic/metering_v1alpha/__init__.py delete mode 100644 tests/unit/gapic/multiclusteringress_v1alpha/__init__.py delete mode 100644 tests/unit/gapic/servicemesh_v1alpha/__init__.py diff --git a/docs/cloudauditlogging_v1alpha/services.rst b/docs/cloudauditlogging_v1alpha/services.rst deleted file mode 100644 index 8e59054..0000000 --- a/docs/cloudauditlogging_v1alpha/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Cloudauditlogging v1alpha API -============================================================== -.. toctree:: - :maxdepth: 2 diff --git a/docs/cloudauditlogging_v1alpha/types.rst b/docs/cloudauditlogging_v1alpha/types.rst deleted file mode 100644 index a8de03d..0000000 --- a/docs/cloudauditlogging_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Cloudauditlogging v1alpha API -=========================================================== - -.. automodule:: google.cloud.gkehub.cloudauditlogging_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/configmanagement_v1alpha/services.rst b/docs/configmanagement_v1alpha/services.rst deleted file mode 100644 index 69a930c..0000000 --- a/docs/configmanagement_v1alpha/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Configmanagement v1alpha API -============================================================= -.. toctree:: - :maxdepth: 2 diff --git a/docs/configmanagement_v1alpha/types.rst b/docs/configmanagement_v1alpha/types.rst deleted file mode 100644 index cb8d802..0000000 --- a/docs/configmanagement_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Configmanagement v1alpha API -========================================================== - -.. automodule:: google.cloud.gkehub.configmanagement_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/gkehub_v1alpha/gke_hub.rst b/docs/gkehub_v1alpha/gke_hub.rst deleted file mode 100644 index 35f64dd..0000000 --- a/docs/gkehub_v1alpha/gke_hub.rst +++ /dev/null @@ -1,10 +0,0 @@ -GkeHub ------------------------- - -.. automodule:: google.cloud.gkehub_v1alpha.services.gke_hub - :members: - :inherited-members: - -.. automodule:: google.cloud.gkehub_v1alpha.services.gke_hub.pagers - :members: - :inherited-members: diff --git a/docs/gkehub_v1alpha/services.rst b/docs/gkehub_v1alpha/services.rst deleted file mode 100644 index e3e1d71..0000000 --- a/docs/gkehub_v1alpha/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Gkehub v1alpha API -============================================ -.. toctree:: - :maxdepth: 2 - - gke_hub diff --git a/docs/gkehub_v1alpha/types.rst b/docs/gkehub_v1alpha/types.rst deleted file mode 100644 index 6f3888d..0000000 --- a/docs/gkehub_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub v1alpha API -========================================= - -.. automodule:: google.cloud.gkehub_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/gkehub_v1alpha2/gke_hub.rst b/docs/gkehub_v1alpha2/gke_hub.rst deleted file mode 100644 index 9a2b4b7..0000000 --- a/docs/gkehub_v1alpha2/gke_hub.rst +++ /dev/null @@ -1,10 +0,0 @@ -GkeHub ------------------------- - -.. automodule:: google.cloud.gkehub_v1alpha2.services.gke_hub - :members: - :inherited-members: - -.. automodule:: google.cloud.gkehub_v1alpha2.services.gke_hub.pagers - :members: - :inherited-members: diff --git a/docs/gkehub_v1alpha2/services.rst b/docs/gkehub_v1alpha2/services.rst deleted file mode 100644 index b92fd6f..0000000 --- a/docs/gkehub_v1alpha2/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Gkehub v1alpha2 API -============================================= -.. toctree:: - :maxdepth: 2 - - gke_hub diff --git a/docs/gkehub_v1alpha2/types.rst b/docs/gkehub_v1alpha2/types.rst deleted file mode 100644 index 475cab1..0000000 --- a/docs/gkehub_v1alpha2/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub v1alpha2 API -========================================== - -.. automodule:: google.cloud.gkehub_v1alpha2.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/metering_v1alpha/services.rst b/docs/metering_v1alpha/services.rst deleted file mode 100644 index aaee9de..0000000 --- a/docs/metering_v1alpha/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Metering v1alpha API -===================================================== -.. toctree:: - :maxdepth: 2 diff --git a/docs/metering_v1alpha/types.rst b/docs/metering_v1alpha/types.rst deleted file mode 100644 index 38cbdd9..0000000 --- a/docs/metering_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Metering v1alpha API -================================================== - -.. automodule:: google.cloud.gkehub.metering_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/multiclusteringress_v1alpha/services.rst b/docs/multiclusteringress_v1alpha/services.rst deleted file mode 100644 index 61a1cb8..0000000 --- a/docs/multiclusteringress_v1alpha/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Multiclusteringress v1alpha API -================================================================ -.. toctree:: - :maxdepth: 2 diff --git a/docs/multiclusteringress_v1alpha/types.rst b/docs/multiclusteringress_v1alpha/types.rst deleted file mode 100644 index 4ddb168..0000000 --- a/docs/multiclusteringress_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Multiclusteringress v1alpha API -============================================================= - -.. automodule:: google.cloud.gkehub.multiclusteringress_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/servicemesh_v1alpha/services.rst b/docs/servicemesh_v1alpha/services.rst deleted file mode 100644 index 78b9b6d..0000000 --- a/docs/servicemesh_v1alpha/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Servicemesh v1alpha API -======================================================== -.. toctree:: - :maxdepth: 2 diff --git a/docs/servicemesh_v1alpha/types.rst b/docs/servicemesh_v1alpha/types.rst deleted file mode 100644 index c52d85a..0000000 --- a/docs/servicemesh_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Servicemesh v1alpha API -===================================================== - -.. automodule:: google.cloud.gkehub.servicemesh_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/google/cloud/gkehub/cloudauditlogging/__init__.py b/google/cloud/gkehub/cloudauditlogging/__init__.py deleted file mode 100644 index 838c1fb..0000000 --- a/google/cloud/gkehub/cloudauditlogging/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.cloudauditlogging_v1alpha.types.cloudauditlogging import ( - FeatureSpec, -) - -__all__ = ("FeatureSpec",) diff --git a/google/cloud/gkehub/cloudauditlogging/py.typed b/google/cloud/gkehub/cloudauditlogging/py.typed deleted file mode 100644 index 1ae262f..0000000 --- a/google/cloud/gkehub/cloudauditlogging/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-cloudauditlogging package uses inline types. diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py deleted file mode 100644 index f7a66d1..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.cloudauditlogging import FeatureSpec - -__all__ = ("FeatureSpec",) diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json b/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json deleted file mode 100644 index 2967b5d..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.cloudauditlogging_v1alpha", - "protoPackage": "google.cloud.gkehub.cloudauditlogging.v1alpha", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed b/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed deleted file mode 100644 index 1ae262f..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-cloudauditlogging package uses inline types. diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py deleted file mode 100644 index 9e00155..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/types/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .cloudauditlogging import FeatureSpec - -__all__ = ("FeatureSpec",) diff --git a/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py b/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py deleted file mode 100644 index 0f3d3eb..0000000 --- a/google/cloud/gkehub/cloudauditlogging_v1alpha/types/cloudauditlogging.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.cloudauditlogging.v1alpha", manifest={"FeatureSpec",}, -) - - -class FeatureSpec(proto.Message): - r"""**Cloud Audit Logging**: Spec for Audit Logging Allowlisting. - Attributes: - allowlisted_service_accounts (Sequence[str]): - Service account that should be allowlisted to - send the audit logs; eg cloudauditlogging@gcp- - project.iam.gserviceaccount.com. These accounts - must already exist, but do not need to have any - permissions granted to them. The customer's - entitlements will be checked prior to - allowlisting (i.e. the customer must be an - Anthos customer.) - """ - - allowlisted_service_accounts = proto.RepeatedField(proto.STRING, number=1,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/configmanagement_v1alpha/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/__init__.py deleted file mode 100644 index 07c8615..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.configmanagement import BinauthzConfig -from .types.configmanagement import BinauthzState -from .types.configmanagement import BinauthzVersion -from .types.configmanagement import ConfigSync -from .types.configmanagement import ConfigSyncDeploymentState -from .types.configmanagement import ConfigSyncState -from .types.configmanagement import ConfigSyncVersion -from .types.configmanagement import ErrorResource -from .types.configmanagement import GatekeeperDeploymentState -from .types.configmanagement import GitConfig -from .types.configmanagement import GroupVersionKind -from .types.configmanagement import HierarchyControllerConfig -from .types.configmanagement import HierarchyControllerDeploymentState -from .types.configmanagement import HierarchyControllerState -from .types.configmanagement import HierarchyControllerVersion -from .types.configmanagement import InstallError -from .types.configmanagement import MembershipSpec -from .types.configmanagement import MembershipState -from .types.configmanagement import OperatorState -from .types.configmanagement import PolicyController -from .types.configmanagement import PolicyControllerState -from .types.configmanagement import PolicyControllerVersion -from .types.configmanagement import SyncError -from .types.configmanagement import SyncState -from .types.configmanagement import DeploymentState - -__all__ = ( - "BinauthzConfig", - "BinauthzState", - "BinauthzVersion", - "ConfigSync", - "ConfigSyncDeploymentState", - "ConfigSyncState", - "ConfigSyncVersion", - "DeploymentState", - "ErrorResource", - "GatekeeperDeploymentState", - "GitConfig", - "GroupVersionKind", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerState", - "HierarchyControllerVersion", - "InstallError", - "MembershipSpec", - "MembershipState", - "OperatorState", - "PolicyController", - "PolicyControllerState", - "PolicyControllerVersion", - "SyncError", - "SyncState", -) diff --git a/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json b/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json deleted file mode 100644 index d77aedb..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.configmanagement_v1alpha", - "protoPackage": "google.cloud.gkehub.configmanagement.v1alpha", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/configmanagement_v1alpha/py.typed b/google/cloud/gkehub/configmanagement_v1alpha/py.typed deleted file mode 100644 index 5d21684..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py b/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py deleted file mode 100644 index b65646c..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/types/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .configmanagement import ( - BinauthzConfig, - BinauthzState, - BinauthzVersion, - ConfigSync, - ConfigSyncDeploymentState, - ConfigSyncState, - ConfigSyncVersion, - ErrorResource, - GatekeeperDeploymentState, - GitConfig, - GroupVersionKind, - HierarchyControllerConfig, - HierarchyControllerDeploymentState, - HierarchyControllerState, - HierarchyControllerVersion, - InstallError, - MembershipSpec, - MembershipState, - OperatorState, - PolicyController, - PolicyControllerState, - PolicyControllerVersion, - SyncError, - SyncState, - DeploymentState, -) - -__all__ = ( - "BinauthzConfig", - "BinauthzState", - "BinauthzVersion", - "ConfigSync", - "ConfigSyncDeploymentState", - "ConfigSyncState", - "ConfigSyncVersion", - "ErrorResource", - "GatekeeperDeploymentState", - "GitConfig", - "GroupVersionKind", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerState", - "HierarchyControllerVersion", - "InstallError", - "MembershipSpec", - "MembershipState", - "OperatorState", - "PolicyController", - "PolicyControllerState", - "PolicyControllerVersion", - "SyncError", - "SyncState", - "DeploymentState", -) diff --git a/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py deleted file mode 100644 index 22bf2c9..0000000 --- a/google/cloud/gkehub/configmanagement_v1alpha/types/configmanagement.py +++ /dev/null @@ -1,583 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.configmanagement.v1alpha", - manifest={ - "DeploymentState", - "MembershipState", - "MembershipSpec", - "ConfigSync", - "GitConfig", - "PolicyController", - "BinauthzConfig", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerVersion", - "HierarchyControllerState", - "OperatorState", - "InstallError", - "ConfigSyncState", - "ConfigSyncVersion", - "ConfigSyncDeploymentState", - "SyncState", - "SyncError", - "ErrorResource", - "GroupVersionKind", - "PolicyControllerState", - "PolicyControllerVersion", - "BinauthzState", - "BinauthzVersion", - "GatekeeperDeploymentState", - }, -) - - -class DeploymentState(proto.Enum): - r"""Enum representing the state of an ACM's deployment on a - cluster - """ - DEPLOYMENT_STATE_UNSPECIFIED = 0 - NOT_INSTALLED = 1 - INSTALLED = 2 - ERROR = 3 - - -class MembershipState(proto.Message): - r"""**Anthos Config Management**: State for a single cluster. - Attributes: - cluster_name (str): - The user-defined name for the cluster used by - ClusterSelectors to group clusters together. This should - match Membership's membership_name, unless the user - installed ACM on the cluster manually prior to enabling the - ACM hub feature. Unique within a Anthos Config Management - installation. - membership_spec (google.cloud.gkehub.configmanagement_v1alpha.types.MembershipSpec): - Membership configuration in the cluster. This - represents the actual state in the cluster, - while the MembershipSpec in the FeatureSpec - represents the intended state - operator_state (google.cloud.gkehub.configmanagement_v1alpha.types.OperatorState): - Current install status of ACM's Operator - config_sync_state (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncState): - Current sync status - policy_controller_state (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyControllerState): - PolicyController status - binauthz_state (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzState): - Binauthz status - hierarchy_controller_state (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerState): - Hierarchy Controller status - """ - - cluster_name = proto.Field(proto.STRING, number=1,) - membership_spec = proto.Field(proto.MESSAGE, number=2, message="MembershipSpec",) - operator_state = proto.Field(proto.MESSAGE, number=3, message="OperatorState",) - config_sync_state = proto.Field(proto.MESSAGE, number=4, message="ConfigSyncState",) - policy_controller_state = proto.Field( - proto.MESSAGE, number=5, message="PolicyControllerState", - ) - binauthz_state = proto.Field(proto.MESSAGE, number=6, message="BinauthzState",) - hierarchy_controller_state = proto.Field( - proto.MESSAGE, number=7, message="HierarchyControllerState", - ) - - -class MembershipSpec(proto.Message): - r"""**Anthos Config Management**: Configuration for a single cluster. - Intended to parallel the ConfigManagement CR. - - Attributes: - config_sync (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSync): - Config Sync configuration for the cluster. - policy_controller (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyController): - Policy Controller configuration for the - cluster. - binauthz (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzConfig): - Binauthz conifguration for the cluster. - hierarchy_controller (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerConfig): - Hierarchy Controller configuration for the - cluster. - version (str): - Version of ACM installed. - """ - - config_sync = proto.Field(proto.MESSAGE, number=1, message="ConfigSync",) - policy_controller = proto.Field( - proto.MESSAGE, number=2, message="PolicyController", - ) - binauthz = proto.Field(proto.MESSAGE, number=3, message="BinauthzConfig",) - hierarchy_controller = proto.Field( - proto.MESSAGE, number=4, message="HierarchyControllerConfig", - ) - version = proto.Field(proto.STRING, number=10,) - - -class ConfigSync(proto.Message): - r"""Configuration for Config Sync - Attributes: - git (google.cloud.gkehub.configmanagement_v1alpha.types.GitConfig): - Git repo configuration for the cluster. - source_format (str): - Specifies whether the Config Sync Repo is - in “hierarchical” or “unstructured” mode. - """ - - git = proto.Field(proto.MESSAGE, number=7, message="GitConfig",) - source_format = proto.Field(proto.STRING, number=8,) - - -class GitConfig(proto.Message): - r"""Git repo configuration for a single cluster. - Attributes: - sync_repo (str): - The URL of the Git repository to use as the - source of truth. - sync_branch (str): - The branch of the repository to sync from. - Default: master. - policy_dir (str): - The path within the Git repository that - represents the top level of the repo to sync. - Default: the root directory of the repository. - sync_wait_secs (int): - Period in seconds between consecutive syncs. - Default: 15. - sync_rev (str): - Git revision (tag or hash) to check out. - Default HEAD. - secret_type (str): - Type of secret configured for access to the - Git repo. - https_proxy (str): - URL for the HTTPS proxy to be used when - communicating with the Git repo. - gcp_service_account_email (str): - The GCP Service Account Email used for auth when secret_type - is gcpServiceAccount. - """ - - sync_repo = proto.Field(proto.STRING, number=1,) - sync_branch = proto.Field(proto.STRING, number=2,) - policy_dir = proto.Field(proto.STRING, number=3,) - sync_wait_secs = proto.Field(proto.INT64, number=4,) - sync_rev = proto.Field(proto.STRING, number=5,) - secret_type = proto.Field(proto.STRING, number=6,) - https_proxy = proto.Field(proto.STRING, number=7,) - gcp_service_account_email = proto.Field(proto.STRING, number=8,) - - -class PolicyController(proto.Message): - r"""Configuration for Policy Controller - Attributes: - enabled (bool): - Enables the installation of Policy - Controller. If false, the rest of - PolicyController fields take no effect. - template_library_installed (bool): - Installs the default template library along - with Policy Controller. - audit_interval_seconds (int): - Sets the interval for Policy Controller Audit - Scans (in seconds). When set to 0, this disables - audit functionality altogether. - exemptable_namespaces (Sequence[str]): - The set of namespaces that are excluded from - Policy Controller checks. Namespaces do not need - to currently exist on the cluster. - referential_rules_enabled (bool): - Enables the ability to use Constraint - Templates that reference to objects other than - the object currently being evaluated. - log_denies_enabled (bool): - Logs all denies and dry run failures. - mutation_enabled (bool): - Enable users to try out mutation for - PolicyController. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - template_library_installed = proto.Field(proto.BOOL, number=2, optional=True,) - audit_interval_seconds = proto.Field(proto.INT64, number=3, optional=True,) - exemptable_namespaces = proto.RepeatedField(proto.STRING, number=4,) - referential_rules_enabled = proto.Field(proto.BOOL, number=5,) - log_denies_enabled = proto.Field(proto.BOOL, number=6,) - mutation_enabled = proto.Field(proto.BOOL, number=7,) - - -class BinauthzConfig(proto.Message): - r"""Configuration for Binauthz - Attributes: - enabled (bool): - Whether binauthz is enabled in this cluster. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - - -class HierarchyControllerConfig(proto.Message): - r"""Configuration for Hierarchy Controller - Attributes: - enabled (bool): - Whether Hierarchy Controller is enabled in - this cluster. - enable_pod_tree_labels (bool): - Whether pod tree labels are enabled in this - cluster. - enable_hierarchical_resource_quota (bool): - Whether hierarchical resource quota is - enabled in this cluster. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - enable_pod_tree_labels = proto.Field(proto.BOOL, number=2,) - enable_hierarchical_resource_quota = proto.Field(proto.BOOL, number=3,) - - -class HierarchyControllerDeploymentState(proto.Message): - r"""Deployment state for Hierarchy Controller - Attributes: - hnc (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - The deployment state for open source HNC - (e.g. v0.7.0-hc.0) - extension (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - The deployment state for Hierarchy Controller - extension (e.g. v0.7.0-hc.1) - """ - - hnc = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - extension = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - - -class HierarchyControllerVersion(proto.Message): - r"""Version for Hierarchy Controller - Attributes: - hnc (str): - Version for open source HNC - extension (str): - Version for Hierarchy Controller extension - """ - - hnc = proto.Field(proto.STRING, number=1,) - extension = proto.Field(proto.STRING, number=2,) - - -class HierarchyControllerState(proto.Message): - r"""State for Hierarchy Controller - Attributes: - version (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerVersion): - The version for Hierarchy Controller - state (google.cloud.gkehub.configmanagement_v1alpha.types.HierarchyControllerDeploymentState): - The deployment state for Hierarchy Controller - """ - - version = proto.Field( - proto.MESSAGE, number=1, message="HierarchyControllerVersion", - ) - state = proto.Field( - proto.MESSAGE, number=2, message="HierarchyControllerDeploymentState", - ) - - -class OperatorState(proto.Message): - r"""State information for an ACM's Operator - Attributes: - version (str): - The semenatic version number of the operator - deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - The state of the Operator's deployment - errors (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.InstallError]): - Install errors. - """ - - version = proto.Field(proto.STRING, number=1,) - deployment_state = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - errors = proto.RepeatedField(proto.MESSAGE, number=3, message="InstallError",) - - -class InstallError(proto.Message): - r"""Errors pertaining to the installation of ACM - Attributes: - error_message (str): - A string representing the user facing error - message - """ - - error_message = proto.Field(proto.STRING, number=1,) - - -class ConfigSyncState(proto.Message): - r"""State information for ConfigSync - Attributes: - version (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncVersion): - The version of ConfigSync deployed - deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.ConfigSyncDeploymentState): - Information about the deployment of - ConfigSync, including the version of the various - Pods deployed - sync_state (google.cloud.gkehub.configmanagement_v1alpha.types.SyncState): - The state of ConfigSync's process to sync - configs to a cluster - """ - - version = proto.Field(proto.MESSAGE, number=1, message="ConfigSyncVersion",) - deployment_state = proto.Field( - proto.MESSAGE, number=2, message="ConfigSyncDeploymentState", - ) - sync_state = proto.Field(proto.MESSAGE, number=3, message="SyncState",) - - -class ConfigSyncVersion(proto.Message): - r"""Specific versioning information pertaining to ConfigSync's - Pods - - Attributes: - importer (str): - Version of the deployed importer pod - syncer (str): - Version of the deployed syncer pod - git_sync (str): - Version of the deployed git-sync pod - monitor (str): - Version of the deployed monitor pod - reconciler_manager (str): - Version of the deployed reconciler-manager - pod - root_reconciler (str): - Version of the deployed reconciler container - in root-reconciler pod - """ - - importer = proto.Field(proto.STRING, number=1,) - syncer = proto.Field(proto.STRING, number=2,) - git_sync = proto.Field(proto.STRING, number=3,) - monitor = proto.Field(proto.STRING, number=4,) - reconciler_manager = proto.Field(proto.STRING, number=5,) - root_reconciler = proto.Field(proto.STRING, number=6,) - - -class ConfigSyncDeploymentState(proto.Message): - r"""The state of ConfigSync's deployment on a cluster - Attributes: - importer (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of the importer pod - syncer (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of the syncer pod - git_sync (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of the git-sync pod - monitor (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of the monitor pod - reconciler_manager (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of reconciler-manager pod - root_reconciler (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Deployment state of root-reconciler - """ - - importer = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - syncer = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - git_sync = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) - monitor = proto.Field(proto.ENUM, number=4, enum="DeploymentState",) - reconciler_manager = proto.Field(proto.ENUM, number=5, enum="DeploymentState",) - root_reconciler = proto.Field(proto.ENUM, number=6, enum="DeploymentState",) - - -class SyncState(proto.Message): - r"""State indicating an ACM's progress syncing configurations to - a cluster - - Attributes: - source_token (str): - Token indicating the state of the repo. - import_token (str): - Token indicating the state of the importer. - sync_token (str): - Token indicating the state of the syncer. - last_sync (str): - Deprecated: use last_sync_time instead. Timestamp of when - ACM last successfully synced the repo The time format is - specified in https://golang.org/pkg/time/#Time.String - last_sync_time (google.protobuf.timestamp_pb2.Timestamp): - Timestamp type of when ACM last successfully - synced the repo - code (google.cloud.gkehub.configmanagement_v1alpha.types.SyncState.SyncCode): - Sync status code - errors (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.SyncError]): - A list of errors resulting from problematic - configs. This list will be truncated after 100 - errors, although it is unlikely for that many - errors to simultaneously exist. - """ - - class SyncCode(proto.Enum): - r"""An enum representing an ACM's status syncing configs to a - cluster - """ - SYNC_CODE_UNSPECIFIED = 0 - SYNCED = 1 - PENDING = 2 - ERROR = 3 - NOT_CONFIGURED = 4 - NOT_INSTALLED = 5 - UNAUTHORIZED = 6 - UNREACHABLE = 7 - - source_token = proto.Field(proto.STRING, number=1,) - import_token = proto.Field(proto.STRING, number=2,) - sync_token = proto.Field(proto.STRING, number=3,) - last_sync = proto.Field(proto.STRING, number=4,) - last_sync_time = proto.Field( - proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, - ) - code = proto.Field(proto.ENUM, number=5, enum=SyncCode,) - errors = proto.RepeatedField(proto.MESSAGE, number=6, message="SyncError",) - - -class SyncError(proto.Message): - r"""An ACM created error representing a problem syncing - configurations - - Attributes: - code (str): - An ACM defined error code - error_message (str): - A description of the error - error_resources (Sequence[google.cloud.gkehub.configmanagement_v1alpha.types.ErrorResource]): - A list of config(s) associated with the - error, if any - """ - - code = proto.Field(proto.STRING, number=1,) - error_message = proto.Field(proto.STRING, number=2,) - error_resources = proto.RepeatedField( - proto.MESSAGE, number=3, message="ErrorResource", - ) - - -class ErrorResource(proto.Message): - r"""Model for a config file in the git repo with an associated - Sync error - - Attributes: - source_path (str): - Path in the git repo of the erroneous config - resource_name (str): - Metadata name of the resource that is causing - an error - resource_namespace (str): - Namespace of the resource that is causing an - error - resource_gvk (google.cloud.gkehub.configmanagement_v1alpha.types.GroupVersionKind): - Group/version/kind of the resource that is - causing an error - """ - - source_path = proto.Field(proto.STRING, number=1,) - resource_name = proto.Field(proto.STRING, number=2,) - resource_namespace = proto.Field(proto.STRING, number=3,) - resource_gvk = proto.Field(proto.MESSAGE, number=4, message="GroupVersionKind",) - - -class GroupVersionKind(proto.Message): - r"""A Kubernetes object's GVK - Attributes: - group (str): - Kubernetes Group - version (str): - Kubernetes Version - kind (str): - Kubernetes Kind - """ - - group = proto.Field(proto.STRING, number=1,) - version = proto.Field(proto.STRING, number=2,) - kind = proto.Field(proto.STRING, number=3,) - - -class PolicyControllerState(proto.Message): - r"""State for PolicyControllerState. - Attributes: - version (google.cloud.gkehub.configmanagement_v1alpha.types.PolicyControllerVersion): - The version of Gatekeeper Policy Controller - deployed. - deployment_state (google.cloud.gkehub.configmanagement_v1alpha.types.GatekeeperDeploymentState): - The state about the policy controller - installation. - """ - - version = proto.Field(proto.MESSAGE, number=1, message="PolicyControllerVersion",) - deployment_state = proto.Field( - proto.MESSAGE, number=2, message="GatekeeperDeploymentState", - ) - - -class PolicyControllerVersion(proto.Message): - r"""The build version of Gatekeeper Policy Controller is using. - Attributes: - version (str): - The gatekeeper image tag that is composed of - ACM version, git tag, build number. - """ - - version = proto.Field(proto.STRING, number=1,) - - -class BinauthzState(proto.Message): - r"""State for Binauthz - Attributes: - webhook (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - The state of the binauthz webhook. - version (google.cloud.gkehub.configmanagement_v1alpha.types.BinauthzVersion): - The version of binauthz that is installed. - """ - - webhook = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - version = proto.Field(proto.MESSAGE, number=2, message="BinauthzVersion",) - - -class BinauthzVersion(proto.Message): - r"""The version of binauthz. - Attributes: - webhook_version (str): - The version of the binauthz webhook. - """ - - webhook_version = proto.Field(proto.STRING, number=1,) - - -class GatekeeperDeploymentState(proto.Message): - r"""State of Policy Controller installation. - Attributes: - gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Status of gatekeeper-controller-manager pod. - gatekeeper_audit (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Status of gatekeeper-audit deployment. - gatekeeper_mutation (google.cloud.gkehub.configmanagement_v1alpha.types.DeploymentState): - Status of the pod serving the mutation - webhook. - """ - - gatekeeper_controller_manager_state = proto.Field( - proto.ENUM, number=1, enum="DeploymentState", - ) - gatekeeper_audit = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - gatekeeper_mutation = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/metering_v1alpha/__init__.py b/google/cloud/gkehub/metering_v1alpha/__init__.py deleted file mode 100644 index 04fad4f..0000000 --- a/google/cloud/gkehub/metering_v1alpha/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.metering import MembershipState - -__all__ = ("MembershipState",) diff --git a/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json b/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json deleted file mode 100644 index 8eb202d..0000000 --- a/google/cloud/gkehub/metering_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.metering_v1alpha", - "protoPackage": "google.cloud.gkehub.metering.v1alpha", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/metering_v1alpha/py.typed b/google/cloud/gkehub/metering_v1alpha/py.typed deleted file mode 100644 index 1947b3f..0000000 --- a/google/cloud/gkehub/metering_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-metering package uses inline types. diff --git a/google/cloud/gkehub/metering_v1alpha/services/__init__.py b/google/cloud/gkehub/metering_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/metering_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/metering_v1alpha/types/__init__.py b/google/cloud/gkehub/metering_v1alpha/types/__init__.py deleted file mode 100644 index 7cf2c8d..0000000 --- a/google/cloud/gkehub/metering_v1alpha/types/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .metering import MembershipState - -__all__ = ("MembershipState",) diff --git a/google/cloud/gkehub/metering_v1alpha/types/metering.py b/google/cloud/gkehub/metering_v1alpha/types/metering.py deleted file mode 100644 index f4de81e..0000000 --- a/google/cloud/gkehub/metering_v1alpha/types/metering.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.metering.v1alpha", manifest={"MembershipState",}, -) - - -class MembershipState(proto.Message): - r"""**Metering**: Per-Membership Feature State. - Attributes: - last_measurement_time (google.protobuf.timestamp_pb2.Timestamp): - The time stamp of the most recent measurement - of the number of vCPUs in the cluster. - precise_last_measured_cluster_vcpu_capacity (float): - The vCPUs capacity in the cluster according - to the most recent measurement (1/1000 - precision). - """ - - last_measurement_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, - ) - precise_last_measured_cluster_vcpu_capacity = proto.Field(proto.FLOAT, number=3,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py deleted file mode 100644 index 661754d..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.multiclusteringress import FeatureSpec -from .types.multiclusteringress import Billing - -__all__ = ( - "Billing", - "FeatureSpec", -) diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json b/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json deleted file mode 100644 index 9965b21..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.multiclusteringress_v1alpha", - "protoPackage": "google.cloud.gkehub.multiclusteringress.v1alpha", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed b/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed deleted file mode 100644 index 298daf2..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py b/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py deleted file mode 100644 index 29ec9f8..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/types/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .multiclusteringress import ( - FeatureSpec, - Billing, -) - -__all__ = ( - "FeatureSpec", - "Billing", -) diff --git a/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py deleted file mode 100644 index 0cee16e..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1alpha/types/multiclusteringress.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.multiclusteringress.v1alpha", - manifest={"Billing", "FeatureSpec",}, -) - - -class Billing(proto.Enum): - r"""Billing identifies which billing structure the customer is - using. - """ - BILLING_UNSPECIFIED = 0 - PAY_AS_YOU_GO = 1 - ANTHOS_LICENSE = 2 - - -class FeatureSpec(proto.Message): - r"""**Multi-cluster Ingress**: The configuration for the - MultiClusterIngress feature. - - Attributes: - config_membership (str): - Fully-qualified Membership name which hosts the - MultiClusterIngress CRD. Example: - ``projects/foo-proj/locations/global/memberships/bar`` - billing (google.cloud.gkehub.multiclusteringress_v1alpha.types.Billing): - Customer's billing structure - """ - - config_membership = proto.Field(proto.STRING, number=1,) - billing = proto.Field(proto.ENUM, number=2, enum="Billing",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/servicemesh/__init__.py b/google/cloud/gkehub/servicemesh/__init__.py deleted file mode 100644 index cf91ada..0000000 --- a/google/cloud/gkehub/servicemesh/__init__.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import AnalysisMessage -from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import ( - AnalysisMessageBase, -) -from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import FeatureState -from google.cloud.gkehub.servicemesh_v1alpha.types.servicemesh import MembershipState - -__all__ = ( - "AnalysisMessage", - "AnalysisMessageBase", - "FeatureState", - "MembershipState", -) diff --git a/google/cloud/gkehub/servicemesh/py.typed b/google/cloud/gkehub/servicemesh/py.typed deleted file mode 100644 index b5ad0fd..0000000 --- a/google/cloud/gkehub/servicemesh/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-servicemesh package uses inline types. diff --git a/google/cloud/gkehub/servicemesh_v1alpha/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/__init__.py deleted file mode 100644 index 92d5f3b..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.servicemesh import AnalysisMessage -from .types.servicemesh import AnalysisMessageBase -from .types.servicemesh import FeatureState -from .types.servicemesh import MembershipState - -__all__ = ( - "AnalysisMessage", - "AnalysisMessageBase", - "FeatureState", - "MembershipState", -) diff --git a/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json b/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json deleted file mode 100644 index 3bf3339..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.servicemesh_v1alpha", - "protoPackage": "google.cloud.gkehub.servicemesh.v1alpha", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/servicemesh_v1alpha/py.typed b/google/cloud/gkehub/servicemesh_v1alpha/py.typed deleted file mode 100644 index b5ad0fd..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-servicemesh package uses inline types. diff --git a/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py b/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py deleted file mode 100644 index f3cc1d6..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/types/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .servicemesh import ( - AnalysisMessage, - AnalysisMessageBase, - FeatureState, - MembershipState, -) - -__all__ = ( - "AnalysisMessage", - "AnalysisMessageBase", - "FeatureState", - "MembershipState", -) diff --git a/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py b/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py deleted file mode 100644 index 9609fc6..0000000 --- a/google/cloud/gkehub/servicemesh_v1alpha/types/servicemesh.py +++ /dev/null @@ -1,145 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.servicemesh.v1alpha", - manifest={ - "FeatureState", - "MembershipState", - "AnalysisMessageBase", - "AnalysisMessage", - }, -) - - -class FeatureState(proto.Message): - r"""**Service Mesh**: State for the whole Hub, as analyzed by the - Service Mesh Hub Controller. - - Attributes: - analysis_messages (Sequence[google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessage]): - Output only. Results of running Service Mesh - analyzers. - """ - - analysis_messages = proto.RepeatedField( - proto.MESSAGE, number=1, message="AnalysisMessage", - ) - - -class MembershipState(proto.Message): - r"""**Service Mesh**: State for a single Membership, as analyzed by the - Service Mesh Hub Controller. - - Attributes: - analysis_messages (Sequence[google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessage]): - Output only. Results of running Service Mesh - analyzers. - """ - - analysis_messages = proto.RepeatedField( - proto.MESSAGE, number=1, message="AnalysisMessage", - ) - - -class AnalysisMessageBase(proto.Message): - r"""AnalysisMessageBase describes some common information that is - needed for all messages. - - Attributes: - type_ (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase.Type): - Represents the specific type of a message. - level (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase.Level): - Represents how severe a message is. - documentation_url (str): - A url pointing to the Service Mesh or Istio - documentation for this specific error type. - """ - - class Level(proto.Enum): - r"""The values here are chosen so that more severe messages get - sorted higher, as well as leaving space in between to add more - later See istio.analysis.v1alpha1.AnalysisMessageBase.Level - """ - LEVEL_UNSPECIFIED = 0 - ERROR = 3 - WARNING = 8 - INFO = 12 - - class Type(proto.Message): - r"""A unique identifier for the type of message. Display_name is - intended to be human-readable, code is intended to be machine - readable. There should be a one-to-one mapping between display_name - and code. (i.e. do not re-use display_names or codes between message - types.) See istio.analysis.v1alpha1.AnalysisMessageBase.Type - - Attributes: - display_name (str): - A human-readable name for the message type. e.g. - "InternalError", "PodMissingProxy". This should be the same - for all messages of the same type. (This corresponds to the - ``name`` field in open-source Istio.) - code (str): - A 7 character code matching ``^IST[0-9]{4}$`` or - ``^ASM[0-9]{4}$``, intended to uniquely identify the message - type. (e.g. "IST0001" is mapped to the "InternalError" - message type.) - """ - - display_name = proto.Field(proto.STRING, number=1,) - code = proto.Field(proto.STRING, number=2,) - - type_ = proto.Field(proto.MESSAGE, number=1, message=Type,) - level = proto.Field(proto.ENUM, number=2, enum=Level,) - documentation_url = proto.Field(proto.STRING, number=3,) - - -class AnalysisMessage(proto.Message): - r"""AnalysisMessage is a single message produced by an analyzer, - and it used to communicate to the end user about the state of - their Service Mesh configuration. - - Attributes: - message_base (google.cloud.gkehub.servicemesh_v1alpha.types.AnalysisMessageBase): - Details common to all types of Istio and - ServiceMesh analysis messages. - description (str): - A human readable description of what the - error means. It is suitable for non- - internationalize display purposes. - resource_paths (Sequence[str]): - A list of strings specifying the resource identifiers that - were the cause of message generation. A "path" here may be: - - - MEMBERSHIP_ID if the cause is a specific member cluster - - MEMBERSHIP_ID/(NAMESPACE/)?RESOURCETYPE/NAME if the cause - is a resource in a cluster - args (google.protobuf.struct_pb2.Struct): - A UI can combine these args with a template (based on - message_base.type) to produce an internationalized message. - """ - - message_base = proto.Field(proto.MESSAGE, number=1, message="AnalysisMessageBase",) - description = proto.Field(proto.STRING, number=2,) - resource_paths = proto.RepeatedField(proto.STRING, number=3,) - args = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Struct,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1alpha/__init__.py b/google/cloud/gkehub_v1alpha/__init__.py deleted file mode 100644 index dcb311b..0000000 --- a/google/cloud/gkehub_v1alpha/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .services.gke_hub import GkeHubClient -from .services.gke_hub import GkeHubAsyncClient - -from .types.feature import CommonFeatureSpec -from .types.feature import CommonFeatureState -from .types.feature import Feature -from .types.feature import FeatureResourceState -from .types.feature import FeatureState -from .types.feature import MembershipFeatureSpec -from .types.feature import MembershipFeatureState -from .types.service import CreateFeatureRequest -from .types.service import DeleteFeatureRequest -from .types.service import GetFeatureRequest -from .types.service import ListFeaturesRequest -from .types.service import ListFeaturesResponse -from .types.service import OperationMetadata -from .types.service import UpdateFeatureRequest - -__all__ = ( - "GkeHubAsyncClient", - "CommonFeatureSpec", - "CommonFeatureState", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "Feature", - "FeatureResourceState", - "FeatureState", - "GetFeatureRequest", - "GkeHubClient", - "ListFeaturesRequest", - "ListFeaturesResponse", - "MembershipFeatureSpec", - "MembershipFeatureState", - "OperationMetadata", - "UpdateFeatureRequest", -) diff --git a/google/cloud/gkehub_v1alpha/gapic_metadata.json b/google/cloud/gkehub_v1alpha/gapic_metadata.json deleted file mode 100644 index eb66ac6..0000000 --- a/google/cloud/gkehub_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,73 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub_v1alpha", - "protoPackage": "google.cloud.gkehub.v1alpha", - "schema": "1.0", - "services": { - "GkeHub": { - "clients": { - "grpc": { - "libraryClient": "GkeHubClient", - "rpcs": { - "CreateFeature": { - "methods": [ - "create_feature" - ] - }, - "DeleteFeature": { - "methods": [ - "delete_feature" - ] - }, - "GetFeature": { - "methods": [ - "get_feature" - ] - }, - "ListFeatures": { - "methods": [ - "list_features" - ] - }, - "UpdateFeature": { - "methods": [ - "update_feature" - ] - } - } - }, - "grpc-async": { - "libraryClient": "GkeHubAsyncClient", - "rpcs": { - "CreateFeature": { - "methods": [ - "create_feature" - ] - }, - "DeleteFeature": { - "methods": [ - "delete_feature" - ] - }, - "GetFeature": { - "methods": [ - "get_feature" - ] - }, - "ListFeatures": { - "methods": [ - "list_features" - ] - }, - "UpdateFeature": { - "methods": [ - "update_feature" - ] - } - } - } - } - } - } -} diff --git a/google/cloud/gkehub_v1alpha/py.typed b/google/cloud/gkehub_v1alpha/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/google/cloud/gkehub_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/google/cloud/gkehub_v1alpha/services/__init__.py b/google/cloud/gkehub_v1alpha/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py b/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py deleted file mode 100644 index 73e44b4..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .client import GkeHubClient -from .async_client import GkeHubAsyncClient - -__all__ = ( - "GkeHubClient", - "GkeHubAsyncClient", -) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py b/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py deleted file mode 100644 index c4398cf..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/async_client.py +++ /dev/null @@ -1,634 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1alpha.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport -from .client import GkeHubClient - - -class GkeHubAsyncClient: - """The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1alpha.Membership] - - [Feature][google.cloud.gkehub.v1alpha.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - """ - - _client: GkeHubClient - - DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT - - feature_path = staticmethod(GkeHubClient.feature_path) - parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) - common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod( - GkeHubClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(GkeHubClient.common_folder_path) - parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) - common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod( - GkeHubClient.parse_common_organization_path - ) - common_project_path = staticmethod(GkeHubClient.common_project_path) - parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) - common_location_path = staticmethod(GkeHubClient.common_location_path) - parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial( - type(GkeHubClient).get_transport_class, type(GkeHubClient) - ) - - def __init__( - self, - *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = GkeHubClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - async def list_features( - self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesAsyncPager: - r"""Lists Features in a given project and location. - - Args: - request (:class:`google.cloud.gkehub_v1alpha.types.ListFeaturesRequest`): - The request object. Request message for - `GkeHub.ListFeatures` method. - parent (:class:`str`): - The parent (project and location) where the Features - will be listed. Specified in the format - ``projects/*/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.gkehub_v1alpha.services.gke_hub.pagers.ListFeaturesAsyncPager: - Response message for the GkeHub.ListFeatures method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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.ListFeaturesRequest(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_features, - 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.ListFeaturesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_feature( - self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: - r"""Gets details of a single Feature. - - Args: - request (:class:`google.cloud.gkehub_v1alpha.types.GetFeatureRequest`): - The request object. Request message for - `GkeHub.GetFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - - 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.gkehub_v1alpha.types.Feature: - Feature represents the settings and - status of any Hub Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = service.GetFeatureRequest(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_feature, - 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 create_feature( - self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Adds a new Feature. - - Args: - request (:class:`google.cloud.gkehub_v1alpha.types.CreateFeatureRequest`): - The request object. Request message for the - `GkeHub.CreateFeature` method. - parent (:class:`str`): - The parent (project and location) where the Feature will - be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1alpha.types.Feature`): - The Feature resource to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - feature_id (:class:`str`): - The ID of the feature to create. - This corresponds to the ``feature_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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if feature_id is not None: - request.feature_id = feature_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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_feature( - self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Removes a Feature. - - Args: - request (:class:`google.cloud.gkehub_v1alpha.types.DeleteFeatureRequest`): - The request object. Request message for - `GkeHub.DeleteFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = service.DeleteFeatureRequest(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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_feature( - self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates an existing Feature. - - Args: - request (:class:`google.cloud.gkehub_v1alpha.types.UpdateFeatureRequest`): - The request object. Request message for - `GkeHub.UpdateFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1alpha.types.Feature`): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. If - you specify the update_mask to be a special path "*", - fully replaces all user-modifiable fields to match - ``resource``. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Mask of fields to update. - 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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.UpdateFeatureRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubAsyncClient",) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/client.py b/google/cloud/gkehub_v1alpha/services/gke_hub/client.py deleted file mode 100644 index d034fea..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/client.py +++ /dev/null @@ -1,827 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1alpha.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import GkeHubGrpcTransport -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -class GkeHubClientMeta(type): - """Metaclass for the GkeHub client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - - _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] - _transport_registry["grpc"] = GkeHubGrpcTransport - _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - - def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class GkeHubClient(metaclass=GkeHubClientMeta): - """The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1alpha.Membership] - - [Feature][google.cloud.gkehub.v1alpha.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "gkehub.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def feature_path(project: str, location: str, feature: str,) -> str: - """Returns a fully-qualified feature string.""" - return "projects/{project}/locations/{location}/features/{feature}".format( - project=project, location=location, feature=feature, - ) - - @staticmethod - def parse_feature_path(path: str) -> Dict[str, str]: - """Parses a feature path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/features/(?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, - ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str, str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str,) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str, str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str,) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str, str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str,) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str, str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - 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, - ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str, str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) - ) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, GkeHubTransport): - # transport is a GkeHubTransport instance. - if credentials or client_options.credentials_file: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def list_features( - self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesPager: - r"""Lists Features in a given project and location. - - Args: - request (google.cloud.gkehub_v1alpha.types.ListFeaturesRequest): - The request object. Request message for - `GkeHub.ListFeatures` method. - parent (str): - The parent (project and location) where the Features - will be listed. Specified in the format - ``projects/*/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.gkehub_v1alpha.services.gke_hub.pagers.ListFeaturesPager: - Response message for the GkeHub.ListFeatures method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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.ListFeaturesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListFeaturesRequest): - request = service.ListFeaturesRequest(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_features] - - # 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.ListFeaturesPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - def get_feature( - self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: - r"""Gets details of a single Feature. - - Args: - request (google.cloud.gkehub_v1alpha.types.GetFeatureRequest): - The request object. Request message for - `GkeHub.GetFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - - 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.gkehub_v1alpha.types.Feature: - Feature represents the settings and - status of any Hub Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetFeatureRequest): - request = service.GetFeatureRequest(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_feature] - - # 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 create_feature( - self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Adds a new Feature. - - Args: - request (google.cloud.gkehub_v1alpha.types.CreateFeatureRequest): - The request object. Request message for the - `GkeHub.CreateFeature` method. - parent (str): - The parent (project and location) where the Feature will - be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1alpha.types.Feature): - The Feature resource to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - feature_id (str): - The ID of the feature to create. - This corresponds to the ``feature_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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateFeatureRequest): - request = service.CreateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if feature_id is not None: - request.feature_id = feature_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_feature] - - # 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,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_feature( - self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Removes a Feature. - - Args: - request (google.cloud.gkehub_v1alpha.types.DeleteFeatureRequest): - The request object. Request message for - `GkeHub.DeleteFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a service.DeleteFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteFeatureRequest): - request = service.DeleteFeatureRequest(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_feature] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_feature( - self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates an existing Feature. - - Args: - request (google.cloud.gkehub_v1alpha.types.UpdateFeatureRequest): - The request object. Request message for - `GkeHub.UpdateFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1alpha.types.Feature): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. If - you specify the update_mask to be a special path "*", - fully replaces all user-modifiable fields to match - ``resource``. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Mask of fields to update. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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.UpdateFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateFeatureRequest): - request = service.UpdateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_feature] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubClient",) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py b/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py deleted file mode 100644 index fba47dc..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/pagers.py +++ /dev/null @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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, - AsyncIterable, - Awaitable, - Callable, - Iterable, - Sequence, - Tuple, - Optional, -) - -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service - - -class ListFeaturesPager: - """A pager for iterating through ``list_features`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFeatures`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` - 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.ListFeaturesResponse], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - 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.gkehub_v1alpha.types.ListFeaturesRequest): - The initial request object. - response (google.cloud.gkehub_v1alpha.types.ListFeaturesResponse): - 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.ListFeaturesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListFeaturesResponse]: - 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) -> Iterable[feature.Feature]: - for page in self.pages: - yield from page.resources - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class ListFeaturesAsyncPager: - """A pager for iterating through ``list_features`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFeatures`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1alpha.types.ListFeaturesResponse` - 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.ListFeaturesResponse]], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - 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.gkehub_v1alpha.types.ListFeaturesRequest): - The initial request object. - response (google.cloud.gkehub_v1alpha.types.ListFeaturesResponse): - 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.ListFeaturesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListFeaturesResponse]: - 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) -> AsyncIterable[feature.Feature]: - async def async_generator(): - async for page in self.pages: - for response in page.resources: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py deleted file mode 100644 index 50e3055..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from typing import Dict, Type - -from .base import GkeHubTransport -from .grpc import GkeHubGrpcTransport -from .grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry["grpc"] = GkeHubGrpcTransport -_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - -__all__ = ( - "GkeHubTransport", - "GkeHubGrpcTransport", - "GkeHubGrpcAsyncIOTransport", -) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py deleted file mode 100644 index 6bfc639..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/base.py +++ /dev/null @@ -1,225 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class GkeHubTransport(abc.ABC): - """Abstract transport class for GkeHub.""" - - AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) - - DEFAULT_HOST: str = "gkehub.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - 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" - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs( - "'credentials_file' and 'credentials' are mutually exclusive" - ) - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id - ) - - # If the credentials is service account credentials, then always try to use self signed JWT. - if ( - always_use_jwt_access - and isinstance(credentials, service_account.Credentials) - and hasattr(service_account.Credentials, "with_always_use_jwt_access") - ): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_features: gapic_v1.method.wrap_method( - self.list_features, default_timeout=None, client_info=client_info, - ), - self.get_feature: gapic_v1.method.wrap_method( - self.get_feature, default_timeout=None, client_info=client_info, - ), - self.create_feature: gapic_v1.method.wrap_method( - self.create_feature, default_timeout=None, client_info=client_info, - ), - self.delete_feature: gapic_v1.method.wrap_method( - self.delete_feature, default_timeout=None, client_info=client_info, - ), - self.update_feature: gapic_v1.method.wrap_method( - self.update_feature, default_timeout=None, client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_features( - self, - ) -> Callable[ - [service.ListFeaturesRequest], - Union[service.ListFeaturesResponse, Awaitable[service.ListFeaturesResponse]], - ]: - raise NotImplementedError() - - @property - def get_feature( - self, - ) -> Callable[ - [service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]] - ]: - raise NotImplementedError() - - @property - def create_feature( - self, - ) -> Callable[ - [service.CreateFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def delete_feature( - self, - ) -> Callable[ - [service.DeleteFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def update_feature( - self, - ) -> Callable[ - [service.UpdateFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - -__all__ = ("GkeHubTransport",) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py deleted file mode 100644 index ddbe160..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc.py +++ /dev/null @@ -1,385 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO - - -class GkeHubGrpcTransport(GkeHubTransport): - """gRPC backend transport for GkeHub. - - The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1alpha.Membership] - - [Feature][google.cloud.gkehub.v1alpha.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _stubs: Dict[str, Callable] - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) - - # Return the client from cache. - return self._operations_client - - @property - def list_features( - self, - ) -> Callable[[service.ListFeaturesRequest], service.ListFeaturesResponse]: - r"""Return a callable for the list features method over gRPC. - - Lists Features in a given project and location. - - Returns: - Callable[[~.ListFeaturesRequest], - ~.ListFeaturesResponse]: - 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_features" not in self._stubs: - self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures", - request_serializer=service.ListFeaturesRequest.serialize, - response_deserializer=service.ListFeaturesResponse.deserialize, - ) - return self._stubs["list_features"] - - @property - def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: - r"""Return a callable for the get feature method over gRPC. - - Gets details of a single Feature. - - Returns: - Callable[[~.GetFeatureRequest], - ~.Feature]: - 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_feature" not in self._stubs: - self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/GetFeature", - request_serializer=service.GetFeatureRequest.serialize, - response_deserializer=feature.Feature.deserialize, - ) - return self._stubs["get_feature"] - - @property - def create_feature( - self, - ) -> Callable[[service.CreateFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the create feature method over gRPC. - - Adds a new Feature. - - Returns: - Callable[[~.CreateFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_feature" not in self._stubs: - self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature", - request_serializer=service.CreateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_feature"] - - @property - def delete_feature( - self, - ) -> Callable[[service.DeleteFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the delete feature method over gRPC. - - Removes a Feature. - - Returns: - Callable[[~.DeleteFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_feature" not in self._stubs: - self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature", - request_serializer=service.DeleteFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_feature"] - - @property - def update_feature( - self, - ) -> Callable[[service.UpdateFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the update feature method over gRPC. - - Updates an existing Feature. - - Returns: - Callable[[~.UpdateFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_feature" not in self._stubs: - self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature", - request_serializer=service.UpdateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_feature"] - - -__all__ = ("GkeHubGrpcTransport",) diff --git a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py deleted file mode 100644 index 0b09308..0000000 --- a/google/cloud/gkehub_v1alpha/services/gke_hub/transports/grpc_asyncio.py +++ /dev/null @@ -1,394 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .grpc import GkeHubGrpcTransport - - -class GkeHubGrpcAsyncIOTransport(GkeHubTransport): - """gRPC AsyncIO backend transport for GkeHub. - - The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1alpha.Membership] - - [Feature][google.cloud.gkehub.v1alpha.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_features( - self, - ) -> Callable[ - [service.ListFeaturesRequest], Awaitable[service.ListFeaturesResponse] - ]: - r"""Return a callable for the list features method over gRPC. - - Lists Features in a given project and location. - - Returns: - Callable[[~.ListFeaturesRequest], - Awaitable[~.ListFeaturesResponse]]: - 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_features" not in self._stubs: - self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/ListFeatures", - request_serializer=service.ListFeaturesRequest.serialize, - response_deserializer=service.ListFeaturesResponse.deserialize, - ) - return self._stubs["list_features"] - - @property - def get_feature( - self, - ) -> Callable[[service.GetFeatureRequest], Awaitable[feature.Feature]]: - r"""Return a callable for the get feature method over gRPC. - - Gets details of a single Feature. - - Returns: - Callable[[~.GetFeatureRequest], - Awaitable[~.Feature]]: - 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_feature" not in self._stubs: - self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/GetFeature", - request_serializer=service.GetFeatureRequest.serialize, - response_deserializer=feature.Feature.deserialize, - ) - return self._stubs["get_feature"] - - @property - def create_feature( - self, - ) -> Callable[[service.CreateFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create feature method over gRPC. - - Adds a new Feature. - - Returns: - Callable[[~.CreateFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_feature" not in self._stubs: - self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/CreateFeature", - request_serializer=service.CreateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_feature"] - - @property - def delete_feature( - self, - ) -> Callable[[service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete feature method over gRPC. - - Removes a Feature. - - Returns: - Callable[[~.DeleteFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_feature" not in self._stubs: - self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/DeleteFeature", - request_serializer=service.DeleteFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_feature"] - - @property - def update_feature( - self, - ) -> Callable[[service.UpdateFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update feature method over gRPC. - - Updates an existing Feature. - - Returns: - Callable[[~.UpdateFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_feature" not in self._stubs: - self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha.GkeHub/UpdateFeature", - request_serializer=service.UpdateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_feature"] - - -__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/google/cloud/gkehub_v1alpha/types/__init__.py b/google/cloud/gkehub_v1alpha/types/__init__.py deleted file mode 100644 index f966a52..0000000 --- a/google/cloud/gkehub_v1alpha/types/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .feature import ( - CommonFeatureSpec, - CommonFeatureState, - Feature, - FeatureResourceState, - FeatureState, - MembershipFeatureSpec, - MembershipFeatureState, -) -from .service import ( - CreateFeatureRequest, - DeleteFeatureRequest, - GetFeatureRequest, - ListFeaturesRequest, - ListFeaturesResponse, - OperationMetadata, - UpdateFeatureRequest, -) - -__all__ = ( - "CommonFeatureSpec", - "CommonFeatureState", - "Feature", - "FeatureResourceState", - "FeatureState", - "MembershipFeatureSpec", - "MembershipFeatureState", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "GetFeatureRequest", - "ListFeaturesRequest", - "ListFeaturesResponse", - "OperationMetadata", - "UpdateFeatureRequest", -) diff --git a/google/cloud/gkehub_v1alpha/types/feature.py b/google/cloud/gkehub_v1alpha/types/feature.py deleted file mode 100644 index c387abb..0000000 --- a/google/cloud/gkehub_v1alpha/types/feature.py +++ /dev/null @@ -1,275 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.cloud.gkehub.cloudauditlogging.v1alpha import cloudauditlogging_pb2 # type: ignore -from google.cloud.gkehub.configmanagement.v1alpha import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.metering.v1alpha import metering_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1alpha import multiclusteringress_pb2 # type: ignore -from google.cloud.gkehub.servicemesh.v1alpha import servicemesh_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.v1alpha", - manifest={ - "Feature", - "FeatureResourceState", - "FeatureState", - "CommonFeatureSpec", - "CommonFeatureState", - "MembershipFeatureSpec", - "MembershipFeatureState", - }, -) - - -class Feature(proto.Message): - r"""Feature represents the settings and status of any Hub - Feature. - - Attributes: - name (str): - Output only. The full, unique name of this Feature resource - in the format ``projects/*/locations/*/features/*``. - labels (Sequence[google.cloud.gkehub_v1alpha.types.Feature.LabelsEntry]): - GCP labels for this Feature. - resource_state (google.cloud.gkehub_v1alpha.types.FeatureResourceState): - Output only. State of the Feature resource - itself. - spec (google.cloud.gkehub_v1alpha.types.CommonFeatureSpec): - Optional. Hub-wide Feature configuration. If - this Feature does not support any Hub-wide - configuration, this field may be unused. - membership_specs (Sequence[google.cloud.gkehub_v1alpha.types.Feature.MembershipSpecsEntry]): - Optional. Membership-specific configuration - for this Feature. If this Feature does not - support any per-Membership configuration, this - field may be unused. - The keys indicate which Membership the - configuration is for, in the form: - projects/{p}/locations/{l}/memberships/{m} - Where {p} is the project, {l} is a valid - location and {m} is a valid Membership in this - project at that location. {p} WILL match the - Feature's project. - - {p} will always be returned as the project - number, but the project ID is also accepted - during input. If the same Membership is - specified in the map twice (using the project ID - form, and the project number form), exactly ONE - of the entries will be saved, with no guarantees - as to which. For this reason, it is recommended - the same format be used for all entries when - mutating a Feature. - state (google.cloud.gkehub_v1alpha.types.CommonFeatureState): - Output only. The Hub-wide Feature state. - membership_states (Sequence[google.cloud.gkehub_v1alpha.types.Feature.MembershipStatesEntry]): - Output only. Membership-specific Feature - status. If this Feature does report any per- - Membership status, this field may be unused. - The keys indicate which Membership the state is - for, in the form: - projects/{p}/locations/{l}/memberships/{m} - Where {p} is the project number, {l} is a valid - location and {m} is a valid Membership in this - project at that location. {p} MUST match the - Feature's project number. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - last updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - deleted. - """ - - name = proto.Field(proto.STRING, number=1,) - labels = proto.MapField(proto.STRING, proto.STRING, number=2,) - resource_state = proto.Field( - proto.MESSAGE, number=3, message="FeatureResourceState", - ) - spec = proto.Field(proto.MESSAGE, number=4, message="CommonFeatureSpec",) - membership_specs = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message="MembershipFeatureSpec", - ) - state = proto.Field(proto.MESSAGE, number=6, message="CommonFeatureState",) - membership_states = proto.MapField( - proto.STRING, proto.MESSAGE, number=7, message="MembershipFeatureState", - ) - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) - delete_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, - ) - - -class FeatureResourceState(proto.Message): - r"""FeatureResourceState describes the state of a Feature *resource* in - the GkeHub API. See ``FeatureState`` for the "running state" of the - Feature in the Hub and across Memberships. - - Attributes: - state (google.cloud.gkehub_v1alpha.types.FeatureResourceState.State): - The current state of the Feature resource in - the Hub API. - """ - - class State(proto.Enum): - r"""State describes the lifecycle status of a Feature.""" - STATE_UNSPECIFIED = 0 - ENABLING = 1 - ACTIVE = 2 - DISABLING = 3 - UPDATING = 4 - SERVICE_UPDATING = 5 - - state = proto.Field(proto.ENUM, number=1, enum=State,) - - -class FeatureState(proto.Message): - r"""FeatureState describes the high-level state of a Feature. It - may be used to describe a Feature's state at the environ-level, - or per-membershop, depending on the context. - - Attributes: - code (google.cloud.gkehub_v1alpha.types.FeatureState.Code): - The high-level, machine-readable status of - this Feature. - description (str): - A human-readable description of the current - status. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time this status and any related Feature- - pecific details were updated. - """ - - class Code(proto.Enum): - r"""Code represents a machine-readable, high-level status of the - Feature. - """ - CODE_UNSPECIFIED = 0 - OK = 1 - WARNING = 2 - ERROR = 3 - - code = proto.Field(proto.ENUM, number=1, enum=Code,) - description = proto.Field(proto.STRING, number=2,) - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - - -class CommonFeatureSpec(proto.Message): - r"""CommonFeatureSpec contains Hub-wide configuration information - Attributes: - multiclusteringress (google.cloud.gkehub.multiclusteringress.v1alpha.multiclusteringress_pb2.FeatureSpec): - Multicluster Ingress-specific spec. - cloudauditlogging (google.cloud.gkehub.cloudauditlogging.v1alpha.cloudauditlogging_pb2.FeatureSpec): - Cloud Audit Logging-specific spec. - """ - - multiclusteringress = proto.Field( - proto.MESSAGE, - number=102, - oneof="feature_spec", - message=multiclusteringress_pb2.FeatureSpec, - ) - cloudauditlogging = proto.Field( - proto.MESSAGE, - number=108, - oneof="feature_spec", - message=cloudauditlogging_pb2.FeatureSpec, - ) - - -class CommonFeatureState(proto.Message): - r"""CommonFeatureState contains Hub-wide Feature status - information. - - Attributes: - servicemesh (google.cloud.gkehub.servicemesh.v1alpha.servicemesh_pb2.FeatureState): - Service Mesh-specific state. - state (google.cloud.gkehub_v1alpha.types.FeatureState): - Output only. The "running state" of the - Feature in this Hub. - """ - - servicemesh = proto.Field( - proto.MESSAGE, - number=100, - oneof="feature_state", - message=servicemesh_pb2.FeatureState, - ) - state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) - - -class MembershipFeatureSpec(proto.Message): - r"""MembershipFeatureSpec contains configuration information for - a single Membership. - - Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1alpha.configmanagement_pb2.MembershipSpec): - Config Management-specific spec. - """ - - configmanagement = proto.Field( - proto.MESSAGE, - number=106, - oneof="feature_spec", - message=configmanagement_pb2.MembershipSpec, - ) - - -class MembershipFeatureState(proto.Message): - r"""MembershipFeatureState contains Feature status information - for a single Membership. - - Attributes: - servicemesh (google.cloud.gkehub.servicemesh.v1alpha.servicemesh_pb2.MembershipState): - Service Mesh-specific state. - metering (google.cloud.gkehub.metering.v1alpha.metering_pb2.MembershipState): - Metering-specific spec. - configmanagement (google.cloud.gkehub.configmanagement.v1alpha.configmanagement_pb2.MembershipState): - Config Management-specific state. - state (google.cloud.gkehub_v1alpha.types.FeatureState): - The high-level state of this Feature for a - single membership. - """ - - servicemesh = proto.Field( - proto.MESSAGE, - number=100, - oneof="feature_state", - message=servicemesh_pb2.MembershipState, - ) - metering = proto.Field( - proto.MESSAGE, - number=104, - oneof="feature_state", - message=metering_pb2.MembershipState, - ) - configmanagement = proto.Field( - proto.MESSAGE, - number=106, - oneof="feature_state", - message=configmanagement_pb2.MembershipState, - ) - state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1alpha/types/service.py b/google/cloud/gkehub_v1alpha/types/service.py deleted file mode 100644 index cdc402b..0000000 --- a/google/cloud/gkehub_v1alpha/types/service.py +++ /dev/null @@ -1,269 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.cloud.gkehub_v1alpha.types import feature -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.v1alpha", - manifest={ - "ListFeaturesRequest", - "ListFeaturesResponse", - "GetFeatureRequest", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "UpdateFeatureRequest", - "OperationMetadata", - }, -) - - -class ListFeaturesRequest(proto.Message): - r"""Request message for ``GkeHub.ListFeatures`` method. - Attributes: - parent (str): - The parent (project and location) where the Features will be - listed. Specified in the format ``projects/*/locations/*``. - page_size (int): - When requesting a 'page' of resources, ``page_size`` - specifies number of resources to return. If unspecified or - set to 0, all resources will be returned. - page_token (str): - Token returned by previous call to ``ListFeatures`` which - specifies the position in the list from where to continue - listing the resources. - filter (str): - Lists Features that match the filter expression, following - the syntax outlined in https://google.aip.dev/160. - - Examples: - - - Feature with the name "servicemesh" in project - "foo-proj": - - name = - "projects/foo-proj/locations/global/features/servicemesh" - - - Features that have a label called ``foo``: - - labels.foo:\* - - - Features that have a label called ``foo`` whose value is - ``bar``: - - labels.foo = bar - order_by (str): - One or more fields to compare and use to sort - the output. See - https://google.aip.dev/132#ordering. - """ - - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) - order_by = proto.Field(proto.STRING, number=5,) - - -class ListFeaturesResponse(proto.Message): - r"""Response message for the ``GkeHub.ListFeatures`` method. - Attributes: - resources (Sequence[google.cloud.gkehub_v1alpha.types.Feature]): - The list of matching Features - next_page_token (str): - A token to request the next page of resources from the - ``ListFeatures`` method. The value of an empty string means - that there are no more resources to return. - """ - - @property - def raw_page(self): - return self - - resources = proto.RepeatedField(proto.MESSAGE, number=1, message=feature.Feature,) - next_page_token = proto.Field(proto.STRING, number=2,) - - -class GetFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.GetFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - """ - - name = proto.Field(proto.STRING, number=1,) - - -class CreateFeatureRequest(proto.Message): - r"""Request message for the ``GkeHub.CreateFeature`` method. - Attributes: - parent (str): - The parent (project and location) where the Feature will be - created. Specified in the format ``projects/*/locations/*``. - feature_id (str): - The ID of the feature to create. - resource (google.cloud.gkehub_v1alpha.types.Feature): - The Feature resource to create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field(proto.STRING, number=1,) - feature_id = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) - request_id = proto.Field(proto.STRING, number=4,) - - -class DeleteFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.DeleteFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - force (bool): - If set to true, the delete will ignore any outstanding - resources for this Feature (that is, - ``FeatureState.has_resources`` is set to true). These - resources will NOT be cleaned up or modified in any way. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - force = proto.Field(proto.BOOL, number=2,) - request_id = proto.Field(proto.STRING, number=3,) - - -class UpdateFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.UpdateFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Mask of fields to update. - resource (google.cloud.gkehub_v1alpha.types.Feature): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are updating a - map field, set the value of a key to null or empty string to - delete the key from the map. It's not possible to update a - key's value to the empty string. If you specify the - update_mask to be a special path "*", fully replaces all - user-modifiable fields to match ``resource``. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, - ) - resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) - request_id = proto.Field(proto.STRING, number=4,) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_detail (str): - Output only. Human-readable status of the - operation, if any. - cancel_requested (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - target = proto.Field(proto.STRING, number=3,) - verb = proto.Field(proto.STRING, number=4,) - status_detail = proto.Field(proto.STRING, number=5,) - cancel_requested = proto.Field(proto.BOOL, number=6,) - api_version = proto.Field(proto.STRING, number=7,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1alpha2/__init__.py b/google/cloud/gkehub_v1alpha2/__init__.py deleted file mode 100644 index 3e4cc54..0000000 --- a/google/cloud/gkehub_v1alpha2/__init__.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .services.gke_hub import GkeHubClient -from .services.gke_hub import GkeHubAsyncClient - -from .types.membership import Authority -from .types.membership import ConnectAgentResource -from .types.membership import CreateMembershipRequest -from .types.membership import DeleteMembershipRequest -from .types.membership import GenerateConnectManifestRequest -from .types.membership import GenerateConnectManifestResponse -from .types.membership import GetMembershipRequest -from .types.membership import GkeCluster -from .types.membership import InitializeHubRequest -from .types.membership import InitializeHubResponse -from .types.membership import KubernetesMetadata -from .types.membership import KubernetesResource -from .types.membership import ListMembershipsRequest -from .types.membership import ListMembershipsResponse -from .types.membership import Membership -from .types.membership import MembershipEndpoint -from .types.membership import MembershipState -from .types.membership import OperationMetadata -from .types.membership import ResourceManifest -from .types.membership import ResourceOptions -from .types.membership import TypeMeta -from .types.membership import UpdateMembershipRequest - -__all__ = ( - "GkeHubAsyncClient", - "Authority", - "ConnectAgentResource", - "CreateMembershipRequest", - "DeleteMembershipRequest", - "GenerateConnectManifestRequest", - "GenerateConnectManifestResponse", - "GetMembershipRequest", - "GkeCluster", - "GkeHubClient", - "InitializeHubRequest", - "InitializeHubResponse", - "KubernetesMetadata", - "KubernetesResource", - "ListMembershipsRequest", - "ListMembershipsResponse", - "Membership", - "MembershipEndpoint", - "MembershipState", - "OperationMetadata", - "ResourceManifest", - "ResourceOptions", - "TypeMeta", - "UpdateMembershipRequest", -) diff --git a/google/cloud/gkehub_v1alpha2/gapic_metadata.json b/google/cloud/gkehub_v1alpha2/gapic_metadata.json deleted file mode 100644 index 5b70423..0000000 --- a/google/cloud/gkehub_v1alpha2/gapic_metadata.json +++ /dev/null @@ -1,93 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub_v1alpha2", - "protoPackage": "google.cloud.gkehub.v1alpha2", - "schema": "1.0", - "services": { - "GkeHub": { - "clients": { - "grpc": { - "libraryClient": "GkeHubClient", - "rpcs": { - "CreateMembership": { - "methods": [ - "create_membership" - ] - }, - "DeleteMembership": { - "methods": [ - "delete_membership" - ] - }, - "GenerateConnectManifest": { - "methods": [ - "generate_connect_manifest" - ] - }, - "GetMembership": { - "methods": [ - "get_membership" - ] - }, - "InitializeHub": { - "methods": [ - "initialize_hub" - ] - }, - "ListMemberships": { - "methods": [ - "list_memberships" - ] - }, - "UpdateMembership": { - "methods": [ - "update_membership" - ] - } - } - }, - "grpc-async": { - "libraryClient": "GkeHubAsyncClient", - "rpcs": { - "CreateMembership": { - "methods": [ - "create_membership" - ] - }, - "DeleteMembership": { - "methods": [ - "delete_membership" - ] - }, - "GenerateConnectManifest": { - "methods": [ - "generate_connect_manifest" - ] - }, - "GetMembership": { - "methods": [ - "get_membership" - ] - }, - "InitializeHub": { - "methods": [ - "initialize_hub" - ] - }, - "ListMemberships": { - "methods": [ - "list_memberships" - ] - }, - "UpdateMembership": { - "methods": [ - "update_membership" - ] - } - } - } - } - } - } -} diff --git a/google/cloud/gkehub_v1alpha2/py.typed b/google/cloud/gkehub_v1alpha2/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/google/cloud/gkehub_v1alpha2/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/google/cloud/gkehub_v1alpha2/services/__init__.py b/google/cloud/gkehub_v1alpha2/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub_v1alpha2/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py deleted file mode 100644 index 73e44b4..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .client import GkeHubClient -from .async_client import GkeHubAsyncClient - -__all__ = ( - "GkeHubClient", - "GkeHubAsyncClient", -) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py deleted file mode 100644 index 1173261..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/async_client.py +++ /dev/null @@ -1,740 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha2.types import membership -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport -from .client import GkeHubClient - - -class GkeHubAsyncClient: - """GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - """ - - _client: GkeHubClient - - DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT - - membership_path = staticmethod(GkeHubClient.membership_path) - parse_membership_path = staticmethod(GkeHubClient.parse_membership_path) - common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod( - GkeHubClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(GkeHubClient.common_folder_path) - parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) - common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod( - GkeHubClient.parse_common_organization_path - ) - common_project_path = staticmethod(GkeHubClient.common_project_path) - parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) - common_location_path = staticmethod(GkeHubClient.common_location_path) - parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial( - type(GkeHubClient).get_transport_class, type(GkeHubClient) - ) - - def __init__( - self, - *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = GkeHubClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - async def list_memberships( - self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsAsyncPager: - r"""Lists Memberships in a given project and location. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsRequest`): - The request object. Request message for - `GkeHub.ListMemberships` method. - parent (:class:`str`): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/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.gkehub_v1alpha2.services.gke_hub.pagers.ListMembershipsAsyncPager: - Response message for the GkeHub.ListMemberships method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 = membership.ListMembershipsRequest(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_memberships, - 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.ListMembershipsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_membership( - self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: - r"""Gets the details of a Membership. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.GetMembershipRequest`): - The request object. Request message for - `GkeHub.GetMembership` method. - name (:class:`str`): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - 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.gkehub_v1alpha2.types.Membership: - Membership contains information about - a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = membership.GetMembershipRequest(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_membership, - 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 create_membership( - self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Adds a new Membership. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.CreateMembershipRequest`): - The request object. Request message for the - `GkeHub.CreateMembership` method. - parent (:class:`str`): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1alpha2.types.Membership`): - Required. The membership to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - membership_id (:class:`str`): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters - or ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length - of 63 characters. - - This corresponds to the ``membership_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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha2.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, membership_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 = membership.CreateMembershipRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if membership_id is not None: - request.membership_id = membership_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_membership, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_membership( - self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Removes a Membership. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.DeleteMembershipRequest`): - The request object. Request message for - `GkeHub.DeleteMembership` method. - name (:class:`str`): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = membership.DeleteMembershipRequest(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_membership, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_membership( - self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates an existing Membership. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.UpdateMembershipRequest`): - The request object. Request message for - `GkeHub.UpdateMembership` method. - name (:class:`str`): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1alpha2.types.Membership`): - Required. Only fields specified in update_mask are - updated. If you specify a field in the update_mask but - don't specify its value here that field will be deleted. - If you are updating a map field, set the value of a key - to null or empty string to delete the key from the map. - It's not possible to update a key's value to the empty - string. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Mask of fields to update. - 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha2.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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 = membership.UpdateMembershipRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_membership, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - async def generate_connect_manifest( - self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: - r"""Generates the manifest for deployment of the GKE - connect agent. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.GenerateConnectManifestRequest`): - The request object. Request message for - `GkeHub.GenerateConnectManifest` method. - . - 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.gkehub_v1alpha2.types.GenerateConnectManifestResponse: - GenerateConnectManifestResponse - contains manifest information for - installing/upgrading a Connect agent. - - """ - # Create or coerce a protobuf request object. - request = membership.GenerateConnectManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.generate_connect_manifest, - 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 initialize_hub( - self, - request: membership.InitializeHubRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.InitializeHubResponse: - r"""Initializes the Hub in this project, which includes - creating the default Hub Service Account and the Hub - Workload Identity Pool. Initialization is optional, and - happens automatically when the first Membership is - created. - InitializeHub should be called when the first Membership - cannot be registered without these resources. A common - example is granting the Hub Service Account access to - another project, which requires the account to exist - first. - - Args: - request (:class:`google.cloud.gkehub_v1alpha2.types.InitializeHubRequest`): - The request object. Request message for the - InitializeHub method. - 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.gkehub_v1alpha2.types.InitializeHubResponse: - Response message for the - InitializeHub method. - - """ - # Create or coerce a protobuf request object. - request = membership.InitializeHubRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.initialize_hub, - 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((("project", request.project),)), - ) - - # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubAsyncClient",) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py deleted file mode 100644 index 7e5bc3e..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/client.py +++ /dev/null @@ -1,937 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha2.types import membership -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import GkeHubGrpcTransport -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -class GkeHubClientMeta(type): - """Metaclass for the GkeHub client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - - _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] - _transport_registry["grpc"] = GkeHubGrpcTransport - _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - - def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class GkeHubClient(metaclass=GkeHubClientMeta): - """GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "gkehub.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def membership_path(project: str, location: str, membership: str,) -> str: - """Returns a fully-qualified membership string.""" - return "projects/{project}/locations/{location}/memberships/{membership}".format( - project=project, location=location, membership=membership, - ) - - @staticmethod - def parse_membership_path(path: str) -> Dict[str, str]: - """Parses a membership path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/memberships/(?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, - ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str, str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str,) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str, str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str,) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str, str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str,) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str, str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - 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, - ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str, str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) - ) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, GkeHubTransport): - # transport is a GkeHubTransport instance. - if credentials or client_options.credentials_file: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def list_memberships( - self, - request: membership.ListMembershipsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMembershipsPager: - r"""Lists Memberships in a given project and location. - - Args: - request (google.cloud.gkehub_v1alpha2.types.ListMembershipsRequest): - The request object. Request message for - `GkeHub.ListMemberships` method. - parent (str): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/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.gkehub_v1alpha2.services.gke_hub.pagers.ListMembershipsPager: - Response message for the GkeHub.ListMemberships method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 membership.ListMembershipsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.ListMembershipsRequest): - request = membership.ListMembershipsRequest(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_memberships] - - # 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.ListMembershipsPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - def get_membership( - self, - request: membership.GetMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.Membership: - r"""Gets the details of a Membership. - - Args: - request (google.cloud.gkehub_v1alpha2.types.GetMembershipRequest): - The request object. Request message for - `GkeHub.GetMembership` method. - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - 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.gkehub_v1alpha2.types.Membership: - Membership contains information about - a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a membership.GetMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.GetMembershipRequest): - request = membership.GetMembershipRequest(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_membership] - - # 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 create_membership( - self, - request: membership.CreateMembershipRequest = None, - *, - parent: str = None, - resource: membership.Membership = None, - membership_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Adds a new Membership. - - Args: - request (google.cloud.gkehub_v1alpha2.types.CreateMembershipRequest): - The request object. Request message for the - `GkeHub.CreateMembership` method. - parent (str): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1alpha2.types.Membership): - Required. The membership to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - membership_id (str): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters - or ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length - of 63 characters. - - This corresponds to the ``membership_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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha2.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, membership_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 membership.CreateMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.CreateMembershipRequest): - request = membership.CreateMembershipRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if membership_id is not None: - request.membership_id = membership_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_membership] - - # 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,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_membership( - self, - request: membership.DeleteMembershipRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Removes a Membership. - - Args: - request (google.cloud.gkehub_v1alpha2.types.DeleteMembershipRequest): - The request object. Request message for - `GkeHub.DeleteMembership` method. - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a membership.DeleteMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.DeleteMembershipRequest): - request = membership.DeleteMembershipRequest(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_membership] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_membership( - self, - request: membership.UpdateMembershipRequest = None, - *, - name: str = None, - resource: membership.Membership = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates an existing Membership. - - Args: - request (google.cloud.gkehub_v1alpha2.types.UpdateMembershipRequest): - The request object. Request message for - `GkeHub.UpdateMembership` method. - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1alpha2.types.Membership): - Required. Only fields specified in update_mask are - updated. If you specify a field in the update_mask but - don't specify its value here that field will be deleted. - If you are updating a map field, set the value of a key - to null or empty string to delete the key from the map. - It's not possible to update a key's value to the empty - string. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1alpha2.types.Membership` - Membership contains information about a member cluster. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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 membership.UpdateMembershipRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.UpdateMembershipRequest): - request = membership.UpdateMembershipRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_membership] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - membership.Membership, - metadata_type=membership.OperationMetadata, - ) - - # Done; return the response. - return response - - def generate_connect_manifest( - self, - request: membership.GenerateConnectManifestRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.GenerateConnectManifestResponse: - r"""Generates the manifest for deployment of the GKE - connect agent. - - Args: - request (google.cloud.gkehub_v1alpha2.types.GenerateConnectManifestRequest): - The request object. Request message for - `GkeHub.GenerateConnectManifest` method. - . - 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.gkehub_v1alpha2.types.GenerateConnectManifestResponse: - GenerateConnectManifestResponse - contains manifest information for - installing/upgrading a Connect agent. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a membership.GenerateConnectManifestRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.GenerateConnectManifestRequest): - request = membership.GenerateConnectManifestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[ - self._transport.generate_connect_manifest - ] - - # 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 initialize_hub( - self, - request: membership.InitializeHubRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> membership.InitializeHubResponse: - r"""Initializes the Hub in this project, which includes - creating the default Hub Service Account and the Hub - Workload Identity Pool. Initialization is optional, and - happens automatically when the first Membership is - created. - InitializeHub should be called when the first Membership - cannot be registered without these resources. A common - example is granting the Hub Service Account access to - another project, which requires the account to exist - first. - - Args: - request (google.cloud.gkehub_v1alpha2.types.InitializeHubRequest): - The request object. Request message for the - InitializeHub method. - 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.gkehub_v1alpha2.types.InitializeHubResponse: - Response message for the - InitializeHub method. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a membership.InitializeHubRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, membership.InitializeHubRequest): - request = membership.InitializeHubRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.initialize_hub] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubClient",) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py deleted file mode 100644 index aa11653..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/pagers.py +++ /dev/null @@ -1,155 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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, - AsyncIterable, - Awaitable, - Callable, - Iterable, - Sequence, - Tuple, - Optional, -) - -from google.cloud.gkehub_v1alpha2.types import membership - - -class ListMembershipsPager: - """A pager for iterating through ``list_memberships`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListMemberships`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` - 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[..., membership.ListMembershipsResponse], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - 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.gkehub_v1alpha2.types.ListMembershipsRequest): - The initial request object. - response (google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse): - 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 = membership.ListMembershipsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[membership.ListMembershipsResponse]: - 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) -> Iterable[membership.Membership]: - for page in self.pages: - yield from page.resources - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class ListMembershipsAsyncPager: - """A pager for iterating through ``list_memberships`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListMemberships`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse` - 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[membership.ListMembershipsResponse]], - request: membership.ListMembershipsRequest, - response: membership.ListMembershipsResponse, - *, - 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.gkehub_v1alpha2.types.ListMembershipsRequest): - The initial request object. - response (google.cloud.gkehub_v1alpha2.types.ListMembershipsResponse): - 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 = membership.ListMembershipsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[membership.ListMembershipsResponse]: - 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) -> AsyncIterable[membership.Membership]: - async def async_generator(): - async for page in self.pages: - for response in page.resources: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py deleted file mode 100644 index 50e3055..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from typing import Dict, Type - -from .base import GkeHubTransport -from .grpc import GkeHubGrpcTransport -from .grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry["grpc"] = GkeHubGrpcTransport -_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - -__all__ = ( - "GkeHubTransport", - "GkeHubGrpcTransport", - "GkeHubGrpcAsyncIOTransport", -) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py deleted file mode 100644 index eafe685..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/base.py +++ /dev/null @@ -1,260 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.gkehub_v1alpha2.types import membership -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class GkeHubTransport(abc.ABC): - """Abstract transport class for GkeHub.""" - - AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) - - DEFAULT_HOST: str = "gkehub.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - 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" - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs( - "'credentials_file' and 'credentials' are mutually exclusive" - ) - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id - ) - - # If the credentials is service account credentials, then always try to use self signed JWT. - if ( - always_use_jwt_access - and isinstance(credentials, service_account.Credentials) - and hasattr(service_account.Credentials, "with_always_use_jwt_access") - ): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_memberships: gapic_v1.method.wrap_method( - self.list_memberships, default_timeout=None, client_info=client_info, - ), - self.get_membership: gapic_v1.method.wrap_method( - self.get_membership, default_timeout=None, client_info=client_info, - ), - self.create_membership: gapic_v1.method.wrap_method( - self.create_membership, default_timeout=None, client_info=client_info, - ), - self.delete_membership: gapic_v1.method.wrap_method( - self.delete_membership, default_timeout=None, client_info=client_info, - ), - self.update_membership: gapic_v1.method.wrap_method( - self.update_membership, default_timeout=None, client_info=client_info, - ), - self.generate_connect_manifest: gapic_v1.method.wrap_method( - self.generate_connect_manifest, - default_timeout=None, - client_info=client_info, - ), - self.initialize_hub: gapic_v1.method.wrap_method( - self.initialize_hub, default_timeout=None, client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_memberships( - self, - ) -> Callable[ - [membership.ListMembershipsRequest], - Union[ - membership.ListMembershipsResponse, - Awaitable[membership.ListMembershipsResponse], - ], - ]: - raise NotImplementedError() - - @property - def get_membership( - self, - ) -> Callable[ - [membership.GetMembershipRequest], - Union[membership.Membership, Awaitable[membership.Membership]], - ]: - raise NotImplementedError() - - @property - def create_membership( - self, - ) -> Callable[ - [membership.CreateMembershipRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def delete_membership( - self, - ) -> Callable[ - [membership.DeleteMembershipRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def update_membership( - self, - ) -> Callable[ - [membership.UpdateMembershipRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def generate_connect_manifest( - self, - ) -> Callable[ - [membership.GenerateConnectManifestRequest], - Union[ - membership.GenerateConnectManifestResponse, - Awaitable[membership.GenerateConnectManifestResponse], - ], - ]: - raise NotImplementedError() - - @property - def initialize_hub( - self, - ) -> Callable[ - [membership.InitializeHubRequest], - Union[ - membership.InitializeHubResponse, - Awaitable[membership.InitializeHubResponse], - ], - ]: - raise NotImplementedError() - - -__all__ = ("GkeHubTransport",) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py deleted file mode 100644 index d096b4f..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc.py +++ /dev/null @@ -1,442 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.gkehub_v1alpha2.types import membership -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO - - -class GkeHubGrpcTransport(GkeHubTransport): - """gRPC backend transport for GkeHub. - - GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _stubs: Dict[str, Callable] - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) - - # Return the client from cache. - return self._operations_client - - @property - def list_memberships( - self, - ) -> Callable[ - [membership.ListMembershipsRequest], membership.ListMembershipsResponse - ]: - r"""Return a callable for the list memberships method over gRPC. - - Lists Memberships in a given project and location. - - Returns: - Callable[[~.ListMembershipsRequest], - ~.ListMembershipsResponse]: - 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_memberships" not in self._stubs: - self._stubs["list_memberships"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships", - request_serializer=membership.ListMembershipsRequest.serialize, - response_deserializer=membership.ListMembershipsResponse.deserialize, - ) - return self._stubs["list_memberships"] - - @property - def get_membership( - self, - ) -> Callable[[membership.GetMembershipRequest], membership.Membership]: - r"""Return a callable for the get membership method over gRPC. - - Gets the details of a Membership. - - Returns: - Callable[[~.GetMembershipRequest], - ~.Membership]: - 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_membership" not in self._stubs: - self._stubs["get_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership", - request_serializer=membership.GetMembershipRequest.serialize, - response_deserializer=membership.Membership.deserialize, - ) - return self._stubs["get_membership"] - - @property - def create_membership( - self, - ) -> Callable[[membership.CreateMembershipRequest], operations_pb2.Operation]: - r"""Return a callable for the create membership method over gRPC. - - Adds a new Membership. - - Returns: - Callable[[~.CreateMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_membership" not in self._stubs: - self._stubs["create_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership", - request_serializer=membership.CreateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_membership"] - - @property - def delete_membership( - self, - ) -> Callable[[membership.DeleteMembershipRequest], operations_pb2.Operation]: - r"""Return a callable for the delete membership method over gRPC. - - Removes a Membership. - - Returns: - Callable[[~.DeleteMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_membership" not in self._stubs: - self._stubs["delete_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership", - request_serializer=membership.DeleteMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_membership"] - - @property - def update_membership( - self, - ) -> Callable[[membership.UpdateMembershipRequest], operations_pb2.Operation]: - r"""Return a callable for the update membership method over gRPC. - - Updates an existing Membership. - - Returns: - Callable[[~.UpdateMembershipRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_membership" not in self._stubs: - self._stubs["update_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership", - request_serializer=membership.UpdateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_membership"] - - @property - def generate_connect_manifest( - self, - ) -> Callable[ - [membership.GenerateConnectManifestRequest], - membership.GenerateConnectManifestResponse, - ]: - r"""Return a callable for the generate connect manifest method over gRPC. - - Generates the manifest for deployment of the GKE - connect agent. - - Returns: - Callable[[~.GenerateConnectManifestRequest], - ~.GenerateConnectManifestResponse]: - 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 "generate_connect_manifest" not in self._stubs: - self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest", - request_serializer=membership.GenerateConnectManifestRequest.serialize, - response_deserializer=membership.GenerateConnectManifestResponse.deserialize, - ) - return self._stubs["generate_connect_manifest"] - - @property - def initialize_hub( - self, - ) -> Callable[[membership.InitializeHubRequest], membership.InitializeHubResponse]: - r"""Return a callable for the initialize hub method over gRPC. - - Initializes the Hub in this project, which includes - creating the default Hub Service Account and the Hub - Workload Identity Pool. Initialization is optional, and - happens automatically when the first Membership is - created. - InitializeHub should be called when the first Membership - cannot be registered without these resources. A common - example is granting the Hub Service Account access to - another project, which requires the account to exist - first. - - Returns: - Callable[[~.InitializeHubRequest], - ~.InitializeHubResponse]: - 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 "initialize_hub" not in self._stubs: - self._stubs["initialize_hub"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub", - request_serializer=membership.InitializeHubRequest.serialize, - response_deserializer=membership.InitializeHubResponse.deserialize, - ) - return self._stubs["initialize_hub"] - - -__all__ = ("GkeHubGrpcTransport",) diff --git a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py deleted file mode 100644 index 2089383..0000000 --- a/google/cloud/gkehub_v1alpha2/services/gke_hub/transports/grpc_asyncio.py +++ /dev/null @@ -1,456 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.gkehub_v1alpha2.types import membership -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .grpc import GkeHubGrpcTransport - - -class GkeHubGrpcAsyncIOTransport(GkeHubTransport): - """gRPC AsyncIO backend transport for GkeHub. - - GKE Hub CRUD API for the Membership resource. - The Membership service is currently only available in the global - location. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_memberships( - self, - ) -> Callable[ - [membership.ListMembershipsRequest], - Awaitable[membership.ListMembershipsResponse], - ]: - r"""Return a callable for the list memberships method over gRPC. - - Lists Memberships in a given project and location. - - Returns: - Callable[[~.ListMembershipsRequest], - Awaitable[~.ListMembershipsResponse]]: - 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_memberships" not in self._stubs: - self._stubs["list_memberships"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/ListMemberships", - request_serializer=membership.ListMembershipsRequest.serialize, - response_deserializer=membership.ListMembershipsResponse.deserialize, - ) - return self._stubs["list_memberships"] - - @property - def get_membership( - self, - ) -> Callable[[membership.GetMembershipRequest], Awaitable[membership.Membership]]: - r"""Return a callable for the get membership method over gRPC. - - Gets the details of a Membership. - - Returns: - Callable[[~.GetMembershipRequest], - Awaitable[~.Membership]]: - 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_membership" not in self._stubs: - self._stubs["get_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/GetMembership", - request_serializer=membership.GetMembershipRequest.serialize, - response_deserializer=membership.Membership.deserialize, - ) - return self._stubs["get_membership"] - - @property - def create_membership( - self, - ) -> Callable[ - [membership.CreateMembershipRequest], Awaitable[operations_pb2.Operation] - ]: - r"""Return a callable for the create membership method over gRPC. - - Adds a new Membership. - - Returns: - Callable[[~.CreateMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_membership" not in self._stubs: - self._stubs["create_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/CreateMembership", - request_serializer=membership.CreateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_membership"] - - @property - def delete_membership( - self, - ) -> Callable[ - [membership.DeleteMembershipRequest], Awaitable[operations_pb2.Operation] - ]: - r"""Return a callable for the delete membership method over gRPC. - - Removes a Membership. - - Returns: - Callable[[~.DeleteMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_membership" not in self._stubs: - self._stubs["delete_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/DeleteMembership", - request_serializer=membership.DeleteMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_membership"] - - @property - def update_membership( - self, - ) -> Callable[ - [membership.UpdateMembershipRequest], Awaitable[operations_pb2.Operation] - ]: - r"""Return a callable for the update membership method over gRPC. - - Updates an existing Membership. - - Returns: - Callable[[~.UpdateMembershipRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_membership" not in self._stubs: - self._stubs["update_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/UpdateMembership", - request_serializer=membership.UpdateMembershipRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_membership"] - - @property - def generate_connect_manifest( - self, - ) -> Callable[ - [membership.GenerateConnectManifestRequest], - Awaitable[membership.GenerateConnectManifestResponse], - ]: - r"""Return a callable for the generate connect manifest method over gRPC. - - Generates the manifest for deployment of the GKE - connect agent. - - Returns: - Callable[[~.GenerateConnectManifestRequest], - Awaitable[~.GenerateConnectManifestResponse]]: - 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 "generate_connect_manifest" not in self._stubs: - self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/GenerateConnectManifest", - request_serializer=membership.GenerateConnectManifestRequest.serialize, - response_deserializer=membership.GenerateConnectManifestResponse.deserialize, - ) - return self._stubs["generate_connect_manifest"] - - @property - def initialize_hub( - self, - ) -> Callable[ - [membership.InitializeHubRequest], Awaitable[membership.InitializeHubResponse] - ]: - r"""Return a callable for the initialize hub method over gRPC. - - Initializes the Hub in this project, which includes - creating the default Hub Service Account and the Hub - Workload Identity Pool. Initialization is optional, and - happens automatically when the first Membership is - created. - InitializeHub should be called when the first Membership - cannot be registered without these resources. A common - example is granting the Hub Service Account access to - another project, which requires the account to exist - first. - - Returns: - Callable[[~.InitializeHubRequest], - Awaitable[~.InitializeHubResponse]]: - 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 "initialize_hub" not in self._stubs: - self._stubs["initialize_hub"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1alpha2.GkeHub/InitializeHub", - request_serializer=membership.InitializeHubRequest.serialize, - response_deserializer=membership.InitializeHubResponse.deserialize, - ) - return self._stubs["initialize_hub"] - - -__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/google/cloud/gkehub_v1alpha2/types/__init__.py b/google/cloud/gkehub_v1alpha2/types/__init__.py deleted file mode 100644 index d9d1009..0000000 --- a/google/cloud/gkehub_v1alpha2/types/__init__.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .membership import ( - Authority, - ConnectAgentResource, - CreateMembershipRequest, - DeleteMembershipRequest, - GenerateConnectManifestRequest, - GenerateConnectManifestResponse, - GetMembershipRequest, - GkeCluster, - InitializeHubRequest, - InitializeHubResponse, - KubernetesMetadata, - KubernetesResource, - ListMembershipsRequest, - ListMembershipsResponse, - Membership, - MembershipEndpoint, - MembershipState, - OperationMetadata, - ResourceManifest, - ResourceOptions, - TypeMeta, - UpdateMembershipRequest, -) - -__all__ = ( - "Authority", - "ConnectAgentResource", - "CreateMembershipRequest", - "DeleteMembershipRequest", - "GenerateConnectManifestRequest", - "GenerateConnectManifestResponse", - "GetMembershipRequest", - "GkeCluster", - "InitializeHubRequest", - "InitializeHubResponse", - "KubernetesMetadata", - "KubernetesResource", - "ListMembershipsRequest", - "ListMembershipsResponse", - "Membership", - "MembershipEndpoint", - "MembershipState", - "OperationMetadata", - "ResourceManifest", - "ResourceOptions", - "TypeMeta", - "UpdateMembershipRequest", -) diff --git a/google/cloud/gkehub_v1alpha2/types/membership.py b/google/cloud/gkehub_v1alpha2/types/membership.py deleted file mode 100644 index ceb6d4a..0000000 --- a/google/cloud/gkehub_v1alpha2/types/membership.py +++ /dev/null @@ -1,724 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.v1alpha2", - manifest={ - "Membership", - "MembershipEndpoint", - "KubernetesResource", - "ResourceOptions", - "GkeCluster", - "KubernetesMetadata", - "Authority", - "MembershipState", - "ListMembershipsRequest", - "ListMembershipsResponse", - "GetMembershipRequest", - "CreateMembershipRequest", - "DeleteMembershipRequest", - "UpdateMembershipRequest", - "GenerateConnectManifestRequest", - "GenerateConnectManifestResponse", - "ConnectAgentResource", - "ResourceManifest", - "TypeMeta", - "InitializeHubRequest", - "InitializeHubResponse", - "OperationMetadata", - }, -) - - -class Membership(proto.Message): - r"""Membership contains information about a member cluster. - Attributes: - name (str): - Output only. The full, unique name of this Membership - resource in the format - ``projects/*/locations/*/memberships/{membership_id}``, set - during creation. - - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters or - ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of - 63 characters. - labels (Sequence[google.cloud.gkehub_v1alpha2.types.Membership.LabelsEntry]): - Optional. GCP labels for this membership. - description (str): - Output only. Description of this membership, limited to 63 - characters. Must match the regex: - ``[a-zA-Z0-9][a-zA-Z0-9_\-\.\ ]*`` - - This field is present for legacy purposes. - endpoint (google.cloud.gkehub_v1alpha2.types.MembershipEndpoint): - Optional. Endpoint information to reach this - member. - state (google.cloud.gkehub_v1alpha2.types.MembershipState): - Output only. State of the Membership - resource. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was last - updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Membership was deleted. - external_id (str): - Optional. An externally-generated and managed ID for this - Membership. This ID may be modified after creation, but this - is not recommended. For GKE clusters, external_id is managed - by the Hub API and updates will be ignored. - - The ID must match the regex: - ``[a-zA-Z0-9][a-zA-Z0-9_\-\.]*`` - - If this Membership represents a Kubernetes cluster, this - value should be set to the UID of the ``kube-system`` - namespace object. - authority (google.cloud.gkehub_v1alpha2.types.Authority): - Optional. How to identify workloads from this - Membership. See the documentation on Workload - Identity for more details: - https://cloud.google.com/kubernetes- - engine/docs/how-to/workload-identity - last_connection_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. For clusters using Connect, the - timestamp of the most recent connection - established with Google Cloud. This time is - updated every several minutes, not continuously. - For clusters that do not use GKE Connect, or - that have never connected successfully, this - field will be unset. - unique_id (str): - Output only. Google-generated UUID for this resource. This - is unique across all Membership resources. If a Membership - resource is deleted and another resource with the same name - is created, it gets a different unique_id. - infrastructure_type (google.cloud.gkehub_v1alpha2.types.Membership.InfrastructureType): - Optional. The infrastructure type this - Membership is running on. - """ - - class InfrastructureType(proto.Enum): - r"""Specifies the infrastructure type of a Membership. - Infrastructure type is used by Hub to control infrastructure- - specific behavior, including pricing. - Each GKE distribution (on-GCP, on-Prem, on-X,...) will set this - field automatically, but Attached Clusters customers should - specify a type during registration. - """ - INFRASTRUCTURE_TYPE_UNSPECIFIED = 0 - ON_PREM = 1 - MULTI_CLOUD = 2 - - name = proto.Field(proto.STRING, number=1,) - labels = proto.MapField(proto.STRING, proto.STRING, number=2,) - description = proto.Field(proto.STRING, number=3,) - endpoint = proto.Field( - proto.MESSAGE, number=4, oneof="type", message="MembershipEndpoint", - ) - state = proto.Field(proto.MESSAGE, number=5, message="MembershipState",) - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) - delete_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) - external_id = proto.Field(proto.STRING, number=9,) - authority = proto.Field(proto.MESSAGE, number=10, message="Authority",) - last_connection_time = proto.Field( - proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, - ) - unique_id = proto.Field(proto.STRING, number=12,) - infrastructure_type = proto.Field(proto.ENUM, number=13, enum=InfrastructureType,) - - -class MembershipEndpoint(proto.Message): - r"""MembershipEndpoint contains information needed to contact a - Kubernetes API, endpoint and any additional Kubernetes metadata. - - Attributes: - gke_cluster (google.cloud.gkehub_v1alpha2.types.GkeCluster): - Optional. GKE-specific information. Only - present if this Membership is a GKE cluster. - kubernetes_metadata (google.cloud.gkehub_v1alpha2.types.KubernetesMetadata): - Output only. Useful Kubernetes-specific - metadata. - kubernetes_resource (google.cloud.gkehub_v1alpha2.types.KubernetesResource): - Optional. The in-cluster Kubernetes Resources that should be - applied for a correctly registered cluster, in the steady - state. These resources: - - - Ensure that the cluster is exclusively registered to one - and only one Hub Membership. - - Propagate Workload Pool Information available in the - Membership Authority field. - - Ensure proper initial configuration of default Hub - Features. - """ - - gke_cluster = proto.Field(proto.MESSAGE, number=1, message="GkeCluster",) - kubernetes_metadata = proto.Field( - proto.MESSAGE, number=2, message="KubernetesMetadata", - ) - kubernetes_resource = proto.Field( - proto.MESSAGE, number=3, message="KubernetesResource", - ) - - -class KubernetesResource(proto.Message): - r"""KubernetesResource contains the YAML manifests and - configuration for Membership Kubernetes resources in the - cluster. After CreateMembership or UpdateMembership, these - resources should be re-applied in the cluster. - - Attributes: - membership_cr_manifest (str): - Input only. The YAML representation of the - Membership CR. This field is ignored for GKE - clusters where Hub can read the CR directly. - Callers should provide the CR that is currently - present in the cluster during Create or Update, - or leave this field empty if none exists. The CR - manifest is used to validate the cluster has not - been registered with another Membership. - membership_resources (Sequence[google.cloud.gkehub_v1alpha2.types.ResourceManifest]): - Output only. Additional Kubernetes resources - that need to be applied to the cluster after - Membership creation, and after every update. - This field is only populated in the Membership - returned from a successful long-running - operation from CreateMembership or - UpdateMembership. It is not populated during - normal GetMembership or ListMemberships - requests. To get the resource manifest after the - initial registration, the caller should make a - UpdateMembership call with an empty field mask. - connect_resources (Sequence[google.cloud.gkehub_v1alpha2.types.ResourceManifest]): - Output only. The Kubernetes resources for - installing the GKE Connect agent. - This field is only populated in the Membership - returned from a successful long-running - operation from CreateMembership or - UpdateMembership. It is not populated during - normal GetMembership or ListMemberships - requests. To get the resource manifest after the - initial registration, the caller should make a - UpdateMembership call with an empty field mask. - resource_options (google.cloud.gkehub_v1alpha2.types.ResourceOptions): - Optional. Options for Kubernetes resource - generation. - """ - - membership_cr_manifest = proto.Field(proto.STRING, number=1,) - membership_resources = proto.RepeatedField( - proto.MESSAGE, number=3, message="ResourceManifest", - ) - connect_resources = proto.RepeatedField( - proto.MESSAGE, number=4, message="ResourceManifest", - ) - resource_options = proto.Field(proto.MESSAGE, number=5, message="ResourceOptions",) - - -class ResourceOptions(proto.Message): - r"""ResourceOptions represent options for Kubernetes resource - generation. - - Attributes: - connect_version (str): - Optional. The Connect agent version to use for - connect_resources. Defaults to the latest GKE Connect - version. The version must be a currently supported version, - obsolete versions will be rejected. - v1beta1_crd (bool): - Optional. Use ``apiextensions/v1beta1`` instead of - ``apiextensions/v1`` for CustomResourceDefinition resources. - This option should be set for clusters with Kubernetes - apiserver versions <1.16. - """ - - connect_version = proto.Field(proto.STRING, number=1,) - v1beta1_crd = proto.Field(proto.BOOL, number=2,) - - -class GkeCluster(proto.Message): - r"""GkeCluster contains information specific to GKE clusters. - Attributes: - resource_link (str): - Immutable. Self-link of the GCP resource for - the GKE cluster. For example: - //container.googleapis.com/projects/my- - project/locations/us-west1-a/clusters/my-cluster - Zonal clusters are also supported. - """ - - resource_link = proto.Field(proto.STRING, number=1,) - - -class KubernetesMetadata(proto.Message): - r"""KubernetesMetadata provides informational metadata for - Memberships that are created from Kubernetes Endpoints - (currently, these are equivalent to Kubernetes clusters). - - Attributes: - kubernetes_api_server_version (str): - Output only. Kubernetes API server version - string as reported by '/version'. - node_provider_id (str): - Output only. Node providerID as reported by the first node - in the list of nodes on the Kubernetes endpoint. On - Kubernetes platforms that support zero-node clusters (like - GKE-on-GCP), the node_count will be zero and the - node_provider_id will be empty. - node_count (int): - Output only. Node count as reported by - Kubernetes nodes resources. - vcpu_count (int): - Output only. vCPU count as reported by - Kubernetes nodes resources. - memory_mb (int): - Output only. The total memory capacity as - reported by the sum of all Kubernetes nodes - resources, defined in MB. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which these details were last - updated. This update_time is different from the - Membership-level update_time since EndpointDetails are - updated internally for API consumers. - """ - - kubernetes_api_server_version = proto.Field(proto.STRING, number=1,) - node_provider_id = proto.Field(proto.STRING, number=2,) - node_count = proto.Field(proto.INT32, number=3,) - vcpu_count = proto.Field(proto.INT32, number=4,) - memory_mb = proto.Field(proto.INT32, number=5,) - update_time = proto.Field( - proto.MESSAGE, number=100, message=timestamp_pb2.Timestamp, - ) - - -class Authority(proto.Message): - r"""Authority encodes how Google will recognize identities from - this Membership. See the workload identity documentation for - more details: https://cloud.google.com/kubernetes- - engine/docs/how-to/workload-identity - - Attributes: - issuer (str): - Optional. A JSON Web Token (JWT) issuer URI. ``issuer`` must - start with ``https://`` and be a valid URL with length <2000 - characters. - - If set, then Google will allow valid OIDC tokens from this - issuer to authenticate within the workload_identity_pool. - OIDC discovery will be performed on this URI to validate - tokens from the issuer, unless ``oidc_jwks`` is set. - - Clearing ``issuer`` disables Workload Identity. ``issuer`` - cannot be directly modified; it must be cleared (and - Workload Identity disabled) before using a new issuer (and - re-enabling Workload Identity). - oidc_jwks (bytes): - Optional. OIDC verification keys for this Membership in JWKS - format (RFC 7517). - - When this field is set, OIDC discovery will NOT be performed - on ``issuer``, and instead OIDC tokens will be validated - using this field. - identity_provider (str): - Output only. An identity provider that reflects the - ``issuer`` in the workload identity pool. - workload_identity_pool (str): - Output only. The name of the workload identity pool in which - ``issuer`` will be recognized. - - There is a single Workload Identity Pool per Hub that is - shared between all Memberships that belong to that Hub. For - a Hub hosted in {PROJECT_ID}, the workload pool format is - ``{PROJECT_ID}.hub.id.goog``, although this is subject to - change in newer versions of this API. - """ - - issuer = proto.Field(proto.STRING, number=1,) - oidc_jwks = proto.Field(proto.BYTES, number=5,) - identity_provider = proto.Field(proto.STRING, number=3,) - workload_identity_pool = proto.Field(proto.STRING, number=4,) - - -class MembershipState(proto.Message): - r"""MembershipState describes the state of a Membership resource. - Attributes: - code (google.cloud.gkehub_v1alpha2.types.MembershipState.Code): - Output only. The current state of the - Membership resource. - """ - - class Code(proto.Enum): - r"""Code describes the state of a Membership resource.""" - CODE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - UPDATING = 4 - SERVICE_UPDATING = 5 - - code = proto.Field(proto.ENUM, number=1, enum=Code,) - - -class ListMembershipsRequest(proto.Message): - r"""Request message for ``GkeHub.ListMemberships`` method. - Attributes: - parent (str): - Required. The parent (project and location) where the - Memberships will be listed. Specified in the format - ``projects/*/locations/*``. - page_size (int): - Optional. When requesting a 'page' of resources, - ``page_size`` specifies number of resources to return. If - unspecified or set to 0, all resources will be returned. - page_token (str): - Optional. Token returned by previous call to - ``ListMemberships`` which specifies the position in the list - from where to continue listing the resources. - filter (str): - Optional. Lists Memberships that match the filter - expression, following the syntax outlined in - https://google.aip.dev/160. - - Examples: - - - Name is ``bar`` in project ``foo-proj`` and location - ``global``: - - name = - "projects/foo-proj/locations/global/membership/bar" - - - Memberships that have a label called ``foo``: - - labels.foo:\* - - - Memberships that have a label called ``foo`` whose value - is ``bar``: - - labels.foo = bar - - - Memberships in the CREATING state: - - state = CREATING - order_by (str): - Optional. One or more fields to compare and - use to sort the output. See - https://google.aip.dev/132#ordering. - """ - - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) - order_by = proto.Field(proto.STRING, number=5,) - - -class ListMembershipsResponse(proto.Message): - r"""Response message for the ``GkeHub.ListMemberships`` method. - Attributes: - resources (Sequence[google.cloud.gkehub_v1alpha2.types.Membership]): - The list of matching Memberships. - next_page_token (str): - A token to request the next page of resources from the - ``ListMemberships`` method. The value of an empty string - means that there are no more resources to return. - unreachable (Sequence[str]): - List of locations that could not be reached - while fetching this list. - """ - - @property - def raw_page(self): - return self - - resources = proto.RepeatedField(proto.MESSAGE, number=1, message="Membership",) - next_page_token = proto.Field(proto.STRING, number=2,) - unreachable = proto.RepeatedField(proto.STRING, number=3,) - - -class GetMembershipRequest(proto.Message): - r"""Request message for ``GkeHub.GetMembership`` method. - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - """ - - name = proto.Field(proto.STRING, number=1,) - - -class CreateMembershipRequest(proto.Message): - r"""Request message for the ``GkeHub.CreateMembership`` method. - Attributes: - parent (str): - Required. The parent (project and location) where the - Memberships will be created. Specified in the format - ``projects/*/locations/*``. - membership_id (str): - Required. Client chosen ID for the membership. - ``membership_id`` must be a valid RFC 1123 compliant DNS - label: - - 1. At most 63 characters in length - 2. It must consist of lower case alphanumeric characters or - ``-`` - 3. It must start and end with an alphanumeric character - - Which can be expressed as the regex: - ``[a-z0-9]([-a-z0-9]*[a-z0-9])?``, with a maximum length of - 63 characters. - resource (google.cloud.gkehub_v1alpha2.types.Membership): - Required. The membership to create. - """ - - parent = proto.Field(proto.STRING, number=1,) - membership_id = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message="Membership",) - - -class DeleteMembershipRequest(proto.Message): - r"""Request message for ``GkeHub.DeleteMembership`` method. - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - """ - - name = proto.Field(proto.STRING, number=1,) - - -class UpdateMembershipRequest(proto.Message): - r"""Request message for ``GkeHub.UpdateMembership`` method. - Attributes: - name (str): - Required. The Membership resource name in the format - ``projects/*/locations/*/memberships/*``. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. - resource (google.cloud.gkehub_v1alpha2.types.Membership): - Required. Only fields specified in update_mask are updated. - If you specify a field in the update_mask but don't specify - its value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. - """ - - name = proto.Field(proto.STRING, number=1,) - update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, - ) - resource = proto.Field(proto.MESSAGE, number=3, message="Membership",) - - -class GenerateConnectManifestRequest(proto.Message): - r"""Request message for ``GkeHub.GenerateConnectManifest`` method. . - Attributes: - name (str): - Required. The Membership resource name the Agent will - associate with, in the format - ``projects/*/locations/*/memberships/*``. - namespace (str): - Optional. Namespace for GKE Connect agent resources. - Defaults to ``gke-connect``. - - The Connect Agent is authorized automatically when run in - the default namespace. Otherwise, explicit authorization - must be granted with an additional IAM binding. - proxy (bytes): - Optional. URI of a proxy if connectivity from the agent to - gkeconnect.googleapis.com requires the use of a proxy. - Format must be in the form ``http(s)://{proxy_address}``, - depending on the HTTP/HTTPS protocol supported by the proxy. - This will direct the connect agent's outbound traffic - through a HTTP(S) proxy. - version (str): - Optional. The Connect agent version to use. - Defaults to the most current version. - is_upgrade (bool): - Optional. If true, generate the resources for - upgrade only. Some resources generated only for - installation (e.g. secrets) will be excluded. - registry (str): - Optional. The registry to fetch the connect - agent image from. Defaults to gcr.io/gkeconnect. - image_pull_secret_content (bytes): - Optional. The image pull secret content for - the registry, if not public. - """ - - name = proto.Field(proto.STRING, number=1,) - namespace = proto.Field(proto.STRING, number=2,) - proxy = proto.Field(proto.BYTES, number=3,) - version = proto.Field(proto.STRING, number=4,) - is_upgrade = proto.Field(proto.BOOL, number=5,) - registry = proto.Field(proto.STRING, number=6,) - image_pull_secret_content = proto.Field(proto.BYTES, number=7,) - - -class GenerateConnectManifestResponse(proto.Message): - r"""GenerateConnectManifestResponse contains manifest information - for installing/upgrading a Connect agent. - - Attributes: - manifest (Sequence[google.cloud.gkehub_v1alpha2.types.ConnectAgentResource]): - The ordered list of Kubernetes resources that - need to be applied to the cluster for GKE - Connect agent installation/upgrade. - """ - - manifest = proto.RepeatedField( - proto.MESSAGE, number=1, message="ConnectAgentResource", - ) - - -class ConnectAgentResource(proto.Message): - r"""ConnectAgentResource represents a Kubernetes resource - manifest for Connect Agent deployment. - - Attributes: - type_ (google.cloud.gkehub_v1alpha2.types.TypeMeta): - Kubernetes type of the resource. - manifest (str): - YAML manifest of the resource. - """ - - type_ = proto.Field(proto.MESSAGE, number=1, message="TypeMeta",) - manifest = proto.Field(proto.STRING, number=2,) - - -class ResourceManifest(proto.Message): - r"""ResourceManifest represents a single Kubernetes resource to - be applied to the cluster. - - Attributes: - manifest (str): - YAML manifest of the resource. - cluster_scoped (bool): - Whether the resource provided in the manifest is - ``cluster_scoped``. If unset, the manifest is assumed to be - namespace scoped. - - This field is used for REST mapping when applying the - resource in a cluster. - """ - - manifest = proto.Field(proto.STRING, number=1,) - cluster_scoped = proto.Field(proto.BOOL, number=2,) - - -class TypeMeta(proto.Message): - r"""TypeMeta is the type information needed for content - unmarshalling of Kubernetes resources in the manifest. - - Attributes: - kind (str): - Kind of the resource (e.g. Deployment). - api_version (str): - APIVersion of the resource (e.g. v1). - """ - - kind = proto.Field(proto.STRING, number=1,) - api_version = proto.Field(proto.STRING, number=2,) - - -class InitializeHubRequest(proto.Message): - r"""Request message for the InitializeHub method. - Attributes: - project (str): - Required. The Hub to initialize, in the format - ``projects/*/locations/*/memberships/*``. - """ - - project = proto.Field(proto.STRING, number=1,) - - -class InitializeHubResponse(proto.Message): - r"""Response message for the InitializeHub method. - Attributes: - service_identity (str): - Name of the Hub default service identity, in the format: - - :: - - service-@gcp-sa-gkehub.iam.gserviceaccount.com - - The service account has ``roles/gkehub.serviceAgent`` in the - Hub project. - workload_identity_pool (str): - The Workload Identity Pool used for Workload - Identity-enabled clusters registered with this Hub. Format: - ``.hub.id.goog`` - """ - - service_identity = proto.Field(proto.STRING, number=1,) - workload_identity_pool = proto.Field(proto.STRING, number=2,) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_detail (str): - Output only. Human-readable status of the - operation, if any. - cancel_requested (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - target = proto.Field(proto.STRING, number=3,) - verb = proto.Field(proto.STRING, number=4,) - status_detail = proto.Field(proto.STRING, number=5,) - cancel_requested = proto.Field(proto.BOOL, number=6,) - api_version = proto.Field(proto.STRING, number=7,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_cloudauditlogging_v1alpha_keywords.py b/scripts/fixup_cloudauditlogging_v1alpha_keywords.py deleted file mode 100644 index 5b4c228..0000000 --- a/scripts/fixup_cloudauditlogging_v1alpha_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class cloudauditloggingCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=cloudauditloggingCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the cloudauditlogging client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_configmanagement_v1alpha_keywords.py b/scripts/fixup_configmanagement_v1alpha_keywords.py deleted file mode 100644 index b06f1d0..0000000 --- a/scripts/fixup_configmanagement_v1alpha_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class configmanagementCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=configmanagementCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the configmanagement client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_gkehub_v1alpha2_keywords.py b/scripts/fixup_gkehub_v1alpha2_keywords.py deleted file mode 100644 index 830ead8..0000000 --- a/scripts/fixup_gkehub_v1alpha2_keywords.py +++ /dev/null @@ -1,182 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class gkehubCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_membership': ('parent', 'membership_id', 'resource', ), - 'delete_membership': ('name', ), - 'generate_connect_manifest': ('name', 'namespace', 'proxy', 'version', 'is_upgrade', 'registry', 'image_pull_secret_content', ), - 'get_membership': ('name', ), - 'initialize_hub': ('project', ), - 'list_memberships': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_membership': ('name', 'update_mask', 'resource', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=gkehubCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the gkehub client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_gkehub_v1alpha_keywords.py b/scripts/fixup_gkehub_v1alpha_keywords.py deleted file mode 100644 index fadc530..0000000 --- a/scripts/fixup_gkehub_v1alpha_keywords.py +++ /dev/null @@ -1,180 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class gkehubCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_feature': ('parent', 'feature_id', 'resource', 'request_id', ), - 'delete_feature': ('name', 'force', 'request_id', ), - 'get_feature': ('name', ), - 'list_features': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_feature': ('name', 'update_mask', 'resource', 'request_id', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=gkehubCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the gkehub client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_metering_v1alpha_keywords.py b/scripts/fixup_metering_v1alpha_keywords.py deleted file mode 100644 index 53d00e3..0000000 --- a/scripts/fixup_metering_v1alpha_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class meteringCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=meteringCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the metering client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_multiclusteringress_v1alpha_keywords.py b/scripts/fixup_multiclusteringress_v1alpha_keywords.py deleted file mode 100644 index e15ebbc..0000000 --- a/scripts/fixup_multiclusteringress_v1alpha_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class multiclusteringressCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=multiclusteringressCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the multiclusteringress client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_servicemesh_v1alpha_keywords.py b/scripts/fixup_servicemesh_v1alpha_keywords.py deleted file mode 100644 index 90afc52..0000000 --- a/scripts/fixup_servicemesh_v1alpha_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class servicemeshCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=servicemeshCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the servicemesh client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py b/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/cloudauditlogging_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/configmanagement_v1alpha/__init__.py b/tests/unit/gapic/configmanagement_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/configmanagement_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/gkehub_v1alpha/__init__.py b/tests/unit/gapic/gkehub_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/gkehub_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py b/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py deleted file mode 100644 index 59e5484..0000000 --- a/tests/unit/gapic/gkehub_v1alpha/test_gke_hub.py +++ /dev/null @@ -1,2178 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -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 operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub.cloudauditlogging.v1alpha import cloudauditlogging_pb2 # type: ignore -from google.cloud.gkehub.configmanagement.v1alpha import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.metering.v1alpha import metering_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1alpha import multiclusteringress_pb2 # type: ignore -from google.cloud.gkehub.servicemesh.v1alpha import servicemesh_pb2 # type: ignore -from google.cloud.gkehub_v1alpha.services.gke_hub import GkeHubAsyncClient -from google.cloud.gkehub_v1alpha.services.gke_hub import GkeHubClient -from google.cloud.gkehub_v1alpha.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha.services.gke_hub import transports -from google.cloud.gkehub_v1alpha.services.gke_hub.transports.base import ( - _GOOGLE_AUTH_VERSION, -) -from google.cloud.gkehub_v1alpha.types import feature -from google.cloud.gkehub_v1alpha.types import service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return ( - "foo.googleapis.com" - if ("localhost" in client.DEFAULT_ENDPOINT) - else client.DEFAULT_ENDPOINT - ) - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert GkeHubClient._get_default_mtls_endpoint(None) is None - assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ( - GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_called_with(True) - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_file(client_class): - 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") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_client_get_transport_class(): - transport = GkeHubClient.get_transport_class() - available_transports = [ - transports.GkeHubGrpcTransport, - ] - assert transport in available_transports - - transport = GkeHubClient.get_transport_class("grpc") - assert transport == transports.GkeHubGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -def test_gke_hub_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,use_client_cert_env", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto( - client_class, transport_class, transport_name, use_client_cert_env -): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - options = client_options.ClientOptions( - client_cert_source=client_cert_source_callback - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=client_cert_source_callback, - ): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_scopes( - client_class, transport_class, transport_name -): - # Check the case scopes are provided. - 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) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_credentials_file( - client_class, transport_class, transport_name -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_gke_hub_client_client_options_from_dict(): - with mock.patch( - "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_list_features( - transport: str = "grpc", request_type=service.ListFeaturesRequest -): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse( - next_page_token="next_page_token_value", - ) - response = client.list_features(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.ListFeaturesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == "next_page_token_value" - - -def test_list_features_from_dict(): - test_list_features(request_type=dict) - - -def test_list_features_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - client.list_features() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListFeaturesRequest() - - -@pytest.mark.asyncio -async def test_list_features_async( - transport: str = "grpc_asyncio", request_type=service.ListFeaturesRequest -): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse(next_page_token="next_page_token_value",) - ) - response = await client.list_features(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListFeaturesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_list_features_async_from_dict(): - await test_list_features_async(request_type=dict) - - -def test_list_features_field_headers(): - client = GkeHubClient(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.ListFeaturesRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - call.return_value = service.ListFeaturesResponse() - client.list_features(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_features_field_headers_async(): - client = GkeHubAsyncClient(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.ListFeaturesRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse() - ) - await client.list_features(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_features_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_features(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] - assert args[0].parent == "parent_value" - - -def test_list_features_flattened_error(): - client = GkeHubClient(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_features( - service.ListFeaturesRequest(), parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_features_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_features(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] - assert args[0].parent == "parent_value" - - -@pytest.mark.asyncio -async def test_list_features_flattened_error_async(): - client = GkeHubAsyncClient(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_features( - service.ListFeaturesRequest(), parent="parent_value", - ) - - -def test_list_features_pager(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_features(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, feature.Feature) for i in results) - - -def test_list_features_pages(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - pages = list(client.list_features(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_features_async_pager(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - async_pager = await client.list_features(request={},) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, feature.Feature) for i in responses) - - -@pytest.mark.asyncio -async def test_list_features_async_pages(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_features(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_get_feature(transport: str = "grpc", request_type=service.GetFeatureRequest): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature(name="name_value",) - response = client.get_feature(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.GetFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, feature.Feature) - assert response.name == "name_value" - - -def test_get_feature_from_dict(): - test_get_feature(request_type=dict) - - -def test_get_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.get_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetFeatureRequest() - - -@pytest.mark.asyncio -async def test_get_feature_async( - transport: str = "grpc_asyncio", request_type=service.GetFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - feature.Feature(name="name_value",) - ) - response = await client.get_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, feature.Feature) - assert response.name == "name_value" - - -@pytest.mark.asyncio -async def test_get_feature_async_from_dict(): - await test_get_feature_async(request_type=dict) - - -def test_get_feature_field_headers(): - client = GkeHubClient(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.GetFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - call.return_value = feature.Feature() - client.get_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.GetFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) - await client.get_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_get_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.GetFeatureRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_get_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.GetFeatureRequest(), name="name_value", - ) - - -def test_create_feature( - transport: str = "grpc", request_type=service.CreateFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_feature(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.CreateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_feature_from_dict(): - test_create_feature(request_type=dict) - - -def test_create_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.create_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateFeatureRequest() - - -@pytest.mark.asyncio -async def test_create_feature_async( - transport: str = "grpc_asyncio", request_type=service.CreateFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.create_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_feature_async_from_dict(): - await test_create_feature_async(request_type=dict) - - -def test_create_feature_field_headers(): - client = GkeHubClient(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.CreateFeatureRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.CreateFeatureRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.create_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_feature( - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_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] - assert args[0].parent == "parent_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].feature_id == "feature_id_value" - - -def test_create_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.CreateFeatureRequest(), - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_id_value", - ) - - -@pytest.mark.asyncio -async def test_create_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_feature( - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_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] - assert args[0].parent == "parent_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].feature_id == "feature_id_value" - - -@pytest.mark.asyncio -async def test_create_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.CreateFeatureRequest(), - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_id_value", - ) - - -def test_delete_feature( - transport: str = "grpc", request_type=service.DeleteFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_feature(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.DeleteFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_feature_from_dict(): - test_delete_feature(request_type=dict) - - -def test_delete_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.delete_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteFeatureRequest() - - -@pytest.mark.asyncio -async def test_delete_feature_async( - transport: str = "grpc_asyncio", request_type=service.DeleteFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.delete_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_feature_async_from_dict(): - await test_delete_feature_async(request_type=dict) - - -def test_delete_feature_field_headers(): - client = GkeHubClient(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.DeleteFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.DeleteFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_delete_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.DeleteFeatureRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_delete_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.DeleteFeatureRequest(), name="name_value", - ) - - -def test_update_feature( - transport: str = "grpc", request_type=service.UpdateFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_feature(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.UpdateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_feature_from_dict(): - test_update_feature(request_type=dict) - - -def test_update_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.update_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateFeatureRequest() - - -@pytest.mark.asyncio -async def test_update_feature_async( - transport: str = "grpc_asyncio", request_type=service.UpdateFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.update_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_feature_async_from_dict(): - await test_update_feature_async(request_type=dict) - - -def test_update_feature_field_headers(): - client = GkeHubClient(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.UpdateFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_feature(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_update_feature_field_headers_async(): - client = GkeHubAsyncClient(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.UpdateFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.update_feature(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_update_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_feature( - name="name_value", - resource=feature.Feature(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] - assert args[0].name == "name_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -def test_update_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.UpdateFeatureRequest(), - name="name_value", - resource=feature.Feature(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -@pytest.mark.asyncio -async def test_update_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_feature( - name="name_value", - resource=feature.Feature(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] - assert args[0].name == "name_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -@pytest.mark.asyncio -async def test_update_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.UpdateFeatureRequest(), - name="name_value", - resource=feature.Feature(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.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = GkeHubClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.GkeHubGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -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() - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.GkeHubGrpcTransport,) - - -def test_gke_hub_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_gke_hub_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "list_features", - "get_feature", - "create_feature", - "delete_feature", - "update_feature", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_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( - "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): - # 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( - "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -def test_gke_hub_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.cloud.gkehub_v1alpha.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_gte_1_25_0 -def test_gke_hub_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "gkehub.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - scopes=["1", "2"], - default_host="gkehub.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds, - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback, - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, private_key=expected_key - ) - - -def test_gke_hub_host_no_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_host_with_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com:8000" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:8000" - - -def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): - with mock.patch( - "grpc.ssl_channel_credentials", autospec=True - ) as grpc_ssl_channel_cred: - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_adc(transport_class): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_gke_hub_grpc_lro_client(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_gke_hub_grpc_lro_async_client(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_feature_path(): - project = "squid" - location = "clam" - feature = "whelk" - expected = "projects/{project}/locations/{location}/features/{feature}".format( - project=project, location=location, feature=feature, - ) - actual = GkeHubClient.feature_path(project, location, feature) - assert expected == actual - - -def test_parse_feature_path(): - expected = { - "project": "octopus", - "location": "oyster", - "feature": "nudibranch", - } - path = GkeHubClient.feature_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_feature_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = GkeHubClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = GkeHubClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) - actual = GkeHubClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = GkeHubClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) - actual = GkeHubClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = GkeHubClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project,) - actual = GkeHubClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = GkeHubClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_project_path(path) - assert expected == actual - - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format( - project=project, location=location, - ) - actual = GkeHubClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = GkeHubClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = GkeHubClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/gkehub_v1alpha2/__init__.py b/tests/unit/gapic/gkehub_v1alpha2/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/gkehub_v1alpha2/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py b/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py deleted file mode 100644 index b6cbfcd..0000000 --- a/tests/unit/gapic/gkehub_v1alpha2/test_gke_hub.py +++ /dev/null @@ -1,2550 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -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 operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub_v1alpha2.services.gke_hub import GkeHubAsyncClient -from google.cloud.gkehub_v1alpha2.services.gke_hub import GkeHubClient -from google.cloud.gkehub_v1alpha2.services.gke_hub import pagers -from google.cloud.gkehub_v1alpha2.services.gke_hub import transports -from google.cloud.gkehub_v1alpha2.services.gke_hub.transports.base import ( - _GOOGLE_AUTH_VERSION, -) -from google.cloud.gkehub_v1alpha2.types import membership -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return ( - "foo.googleapis.com" - if ("localhost" in client.DEFAULT_ENDPOINT) - else client.DEFAULT_ENDPOINT - ) - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert GkeHubClient._get_default_mtls_endpoint(None) is None - assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ( - GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_called_with(True) - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_file(client_class): - 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") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_client_get_transport_class(): - transport = GkeHubClient.get_transport_class() - available_transports = [ - transports.GkeHubGrpcTransport, - ] - assert transport in available_transports - - transport = GkeHubClient.get_transport_class("grpc") - assert transport == transports.GkeHubGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -def test_gke_hub_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,use_client_cert_env", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto( - client_class, transport_class, transport_name, use_client_cert_env -): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - options = client_options.ClientOptions( - client_cert_source=client_cert_source_callback - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=client_cert_source_callback, - ): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_scopes( - client_class, transport_class, transport_name -): - # Check the case scopes are provided. - 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) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_credentials_file( - client_class, transport_class, transport_name -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_gke_hub_client_client_options_from_dict(): - with mock.patch( - "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_list_memberships( - transport: str = "grpc", request_type=membership.ListMembershipsRequest -): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse( - next_page_token="next_page_token_value", unreachable=["unreachable_value"], - ) - response = client.list_memberships(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMembershipsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] - - -def test_list_memberships_from_dict(): - test_list_memberships(request_type=dict) - - -def test_list_memberships_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - client.list_memberships() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - -@pytest.mark.asyncio -async def test_list_memberships_async( - transport: str = "grpc_asyncio", request_type=membership.ListMembershipsRequest -): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.ListMembershipsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - response = await client.list_memberships(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.ListMembershipsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMembershipsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] - - -@pytest.mark.asyncio -async def test_list_memberships_async_from_dict(): - await test_list_memberships_async(request_type=dict) - - -def test_list_memberships_field_headers(): - client = GkeHubClient(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 = membership.ListMembershipsRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - call.return_value = membership.ListMembershipsResponse() - client.list_memberships(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_memberships_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.ListMembershipsRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.ListMembershipsResponse() - ) - await client.list_memberships(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_memberships_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_memberships(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] - assert args[0].parent == "parent_value" - - -def test_list_memberships_flattened_error(): - client = GkeHubClient(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_memberships( - membership.ListMembershipsRequest(), parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_memberships_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.ListMembershipsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.ListMembershipsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_memberships(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] - assert args[0].parent == "parent_value" - - -@pytest.mark.asyncio -async def test_list_memberships_flattened_error_async(): - client = GkeHubAsyncClient(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_memberships( - membership.ListMembershipsRequest(), parent="parent_value", - ) - - -def test_list_memberships_pager(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token="abc", - ), - membership.ListMembershipsResponse(resources=[], next_page_token="def",), - membership.ListMembershipsResponse( - resources=[membership.Membership(),], next_page_token="ghi", - ), - membership.ListMembershipsResponse( - resources=[membership.Membership(), membership.Membership(),], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_memberships(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, membership.Membership) for i in results) - - -def test_list_memberships_pages(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_memberships), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token="abc", - ), - membership.ListMembershipsResponse(resources=[], next_page_token="def",), - membership.ListMembershipsResponse( - resources=[membership.Membership(),], next_page_token="ghi", - ), - membership.ListMembershipsResponse( - resources=[membership.Membership(), membership.Membership(),], - ), - RuntimeError, - ) - pages = list(client.list_memberships(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_memberships_async_pager(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token="abc", - ), - membership.ListMembershipsResponse(resources=[], next_page_token="def",), - membership.ListMembershipsResponse( - resources=[membership.Membership(),], next_page_token="ghi", - ), - membership.ListMembershipsResponse( - resources=[membership.Membership(), membership.Membership(),], - ), - RuntimeError, - ) - async_pager = await client.list_memberships(request={},) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, membership.Membership) for i in responses) - - -@pytest.mark.asyncio -async def test_list_memberships_async_pages(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_memberships), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - membership.ListMembershipsResponse( - resources=[ - membership.Membership(), - membership.Membership(), - membership.Membership(), - ], - next_page_token="abc", - ), - membership.ListMembershipsResponse(resources=[], next_page_token="def",), - membership.ListMembershipsResponse( - resources=[membership.Membership(),], next_page_token="ghi", - ), - membership.ListMembershipsResponse( - resources=[membership.Membership(), membership.Membership(),], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_memberships(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_get_membership( - transport: str = "grpc", request_type=membership.GetMembershipRequest -): - client = GkeHubClient( - 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_membership), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership( - name="name_value", - description="description_value", - external_id="external_id_value", - unique_id="unique_id_value", - infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - endpoint=membership.MembershipEndpoint( - gke_cluster=membership.GkeCluster(resource_link="resource_link_value") - ), - ) - response = client.get_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.Membership) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.external_id == "external_id_value" - assert response.unique_id == "unique_id_value" - assert ( - response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM - ) - - -def test_get_membership_from_dict(): - test_get_membership(request_type=dict) - - -def test_get_membership_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 = GkeHubClient( - 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_membership), "__call__") as call: - client.get_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - -@pytest.mark.asyncio -async def test_get_membership_async( - transport: str = "grpc_asyncio", request_type=membership.GetMembershipRequest -): - client = GkeHubAsyncClient( - 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_membership), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.Membership( - name="name_value", - description="description_value", - external_id="external_id_value", - unique_id="unique_id_value", - infrastructure_type=membership.Membership.InfrastructureType.ON_PREM, - ) - ) - response = await client.get_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GetMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.Membership) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.external_id == "external_id_value" - assert response.unique_id == "unique_id_value" - assert ( - response.infrastructure_type == membership.Membership.InfrastructureType.ON_PREM - ) - - -@pytest.mark.asyncio -async def test_get_membership_async_from_dict(): - await test_get_membership_async(request_type=dict) - - -def test_get_membership_field_headers(): - client = GkeHubClient(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 = membership.GetMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_membership), "__call__") as call: - call.return_value = membership.Membership() - client.get_membership(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_membership_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.GetMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_membership), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.Membership() - ) - await client.get_membership(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_membership_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_membership), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_membership(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_get_membership_flattened_error(): - client = GkeHubClient(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_membership( - membership.GetMembershipRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_membership_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_membership), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.Membership() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.Membership() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_membership(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_get_membership_flattened_error_async(): - client = GkeHubAsyncClient(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_membership( - membership.GetMembershipRequest(), name="name_value", - ) - - -def test_create_membership( - transport: str = "grpc", request_type=membership.CreateMembershipRequest -): - client = GkeHubClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_membership_from_dict(): - test_create_membership(request_type=dict) - - -def test_create_membership_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 = GkeHubClient( - 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_membership), "__call__" - ) as call: - client.create_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - -@pytest.mark.asyncio -async def test_create_membership_async( - transport: str = "grpc_asyncio", request_type=membership.CreateMembershipRequest -): - client = GkeHubAsyncClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.create_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.CreateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_membership_async_from_dict(): - await test_create_membership_async(request_type=dict) - - -def test_create_membership_field_headers(): - client = GkeHubClient(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 = membership.CreateMembershipRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_membership(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_membership_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.CreateMembershipRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.create_membership(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_membership_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_membership( - parent="parent_value", - resource=membership.Membership(name="name_value"), - membership_id="membership_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] - assert args[0].parent == "parent_value" - assert args[0].resource == membership.Membership(name="name_value") - assert args[0].membership_id == "membership_id_value" - - -def test_create_membership_flattened_error(): - client = GkeHubClient(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_membership( - membership.CreateMembershipRequest(), - parent="parent_value", - resource=membership.Membership(name="name_value"), - membership_id="membership_id_value", - ) - - -@pytest.mark.asyncio -async def test_create_membership_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_membership( - parent="parent_value", - resource=membership.Membership(name="name_value"), - membership_id="membership_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] - assert args[0].parent == "parent_value" - assert args[0].resource == membership.Membership(name="name_value") - assert args[0].membership_id == "membership_id_value" - - -@pytest.mark.asyncio -async def test_create_membership_flattened_error_async(): - client = GkeHubAsyncClient(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_membership( - membership.CreateMembershipRequest(), - parent="parent_value", - resource=membership.Membership(name="name_value"), - membership_id="membership_id_value", - ) - - -def test_delete_membership( - transport: str = "grpc", request_type=membership.DeleteMembershipRequest -): - client = GkeHubClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_membership_from_dict(): - test_delete_membership(request_type=dict) - - -def test_delete_membership_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 = GkeHubClient( - 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_membership), "__call__" - ) as call: - client.delete_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - -@pytest.mark.asyncio -async def test_delete_membership_async( - transport: str = "grpc_asyncio", request_type=membership.DeleteMembershipRequest -): - client = GkeHubAsyncClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.delete_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.DeleteMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_membership_async_from_dict(): - await test_delete_membership_async(request_type=dict) - - -def test_delete_membership_field_headers(): - client = GkeHubClient(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 = membership.DeleteMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_membership(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_membership_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.DeleteMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_membership(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_membership_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_membership(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_delete_membership_flattened_error(): - client = GkeHubClient(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_membership( - membership.DeleteMembershipRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_membership_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_membership(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_delete_membership_flattened_error_async(): - client = GkeHubAsyncClient(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_membership( - membership.DeleteMembershipRequest(), name="name_value", - ) - - -def test_update_membership( - transport: str = "grpc", request_type=membership.UpdateMembershipRequest -): - client = GkeHubClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_membership_from_dict(): - test_update_membership(request_type=dict) - - -def test_update_membership_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 = GkeHubClient( - 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_membership), "__call__" - ) as call: - client.update_membership() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - -@pytest.mark.asyncio -async def test_update_membership_async( - transport: str = "grpc_asyncio", request_type=membership.UpdateMembershipRequest -): - client = GkeHubAsyncClient( - 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_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.update_membership(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.UpdateMembershipRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_membership_async_from_dict(): - await test_update_membership_async(request_type=dict) - - -def test_update_membership_field_headers(): - client = GkeHubClient(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 = membership.UpdateMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_membership(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_update_membership_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.UpdateMembershipRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.update_membership(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_update_membership_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_membership( - name="name_value", - resource=membership.Membership(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] - assert args[0].name == "name_value" - assert args[0].resource == membership.Membership(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -def test_update_membership_flattened_error(): - client = GkeHubClient(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_membership( - membership.UpdateMembershipRequest(), - name="name_value", - resource=membership.Membership(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -@pytest.mark.asyncio -async def test_update_membership_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_membership), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_membership( - name="name_value", - resource=membership.Membership(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] - assert args[0].name == "name_value" - assert args[0].resource == membership.Membership(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -@pytest.mark.asyncio -async def test_update_membership_flattened_error_async(): - client = GkeHubAsyncClient(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_membership( - membership.UpdateMembershipRequest(), - name="name_value", - resource=membership.Membership(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -def test_generate_connect_manifest( - transport: str = "grpc", request_type=membership.GenerateConnectManifestRequest -): - client = GkeHubClient( - 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.generate_connect_manifest), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = membership.GenerateConnectManifestResponse() - response = client.generate_connect_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateConnectManifestResponse) - - -def test_generate_connect_manifest_from_dict(): - test_generate_connect_manifest(request_type=dict) - - -def test_generate_connect_manifest_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 = GkeHubClient( - 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.generate_connect_manifest), "__call__" - ) as call: - client.generate_connect_manifest() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - -@pytest.mark.asyncio -async def test_generate_connect_manifest_async( - transport: str = "grpc_asyncio", - request_type=membership.GenerateConnectManifestRequest, -): - client = GkeHubAsyncClient( - 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.generate_connect_manifest), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.GenerateConnectManifestResponse() - ) - response = await client.generate_connect_manifest(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.GenerateConnectManifestRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.GenerateConnectManifestResponse) - - -@pytest.mark.asyncio -async def test_generate_connect_manifest_async_from_dict(): - await test_generate_connect_manifest_async(request_type=dict) - - -def test_generate_connect_manifest_field_headers(): - client = GkeHubClient(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 = membership.GenerateConnectManifestRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_connect_manifest), "__call__" - ) as call: - call.return_value = membership.GenerateConnectManifestResponse() - client.generate_connect_manifest(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_generate_connect_manifest_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.GenerateConnectManifestRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.generate_connect_manifest), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.GenerateConnectManifestResponse() - ) - await client.generate_connect_manifest(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_initialize_hub( - transport: str = "grpc", request_type=membership.InitializeHubRequest -): - client = GkeHubClient( - 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.initialize_hub), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = membership.InitializeHubResponse( - service_identity="service_identity_value", - workload_identity_pool="workload_identity_pool_value", - ) - response = client.initialize_hub(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == membership.InitializeHubRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.InitializeHubResponse) - assert response.service_identity == "service_identity_value" - assert response.workload_identity_pool == "workload_identity_pool_value" - - -def test_initialize_hub_from_dict(): - test_initialize_hub(request_type=dict) - - -def test_initialize_hub_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 = GkeHubClient( - 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.initialize_hub), "__call__") as call: - client.initialize_hub() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == membership.InitializeHubRequest() - - -@pytest.mark.asyncio -async def test_initialize_hub_async( - transport: str = "grpc_asyncio", request_type=membership.InitializeHubRequest -): - client = GkeHubAsyncClient( - 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.initialize_hub), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.InitializeHubResponse( - service_identity="service_identity_value", - workload_identity_pool="workload_identity_pool_value", - ) - ) - response = await client.initialize_hub(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == membership.InitializeHubRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, membership.InitializeHubResponse) - assert response.service_identity == "service_identity_value" - assert response.workload_identity_pool == "workload_identity_pool_value" - - -@pytest.mark.asyncio -async def test_initialize_hub_async_from_dict(): - await test_initialize_hub_async(request_type=dict) - - -def test_initialize_hub_field_headers(): - client = GkeHubClient(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 = membership.InitializeHubRequest() - - request.project = "project/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: - call.return_value = membership.InitializeHubResponse() - client.initialize_hub(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", "project=project/value",) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_initialize_hub_field_headers_async(): - client = GkeHubAsyncClient(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 = membership.InitializeHubRequest() - - request.project = "project/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.initialize_hub), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - membership.InitializeHubResponse() - ) - await client.initialize_hub(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", "project=project/value",) in kw["metadata"] - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = GkeHubClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.GkeHubGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -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() - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.GkeHubGrpcTransport,) - - -def test_gke_hub_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_gke_hub_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "list_memberships", - "get_membership", - "create_membership", - "delete_membership", - "update_membership", - "generate_connect_manifest", - "initialize_hub", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_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( - "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): - # 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( - "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -def test_gke_hub_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.cloud.gkehub_v1alpha2.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_gte_1_25_0 -def test_gke_hub_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "gkehub.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - scopes=["1", "2"], - default_host="gkehub.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds, - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback, - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, private_key=expected_key - ) - - -def test_gke_hub_host_no_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_host_with_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com:8000" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:8000" - - -def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): - with mock.patch( - "grpc.ssl_channel_credentials", autospec=True - ) as grpc_ssl_channel_cred: - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_adc(transport_class): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_gke_hub_grpc_lro_client(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_gke_hub_grpc_lro_async_client(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_membership_path(): - project = "squid" - location = "clam" - membership = "whelk" - expected = "projects/{project}/locations/{location}/memberships/{membership}".format( - project=project, location=location, membership=membership, - ) - actual = GkeHubClient.membership_path(project, location, membership) - assert expected == actual - - -def test_parse_membership_path(): - expected = { - "project": "octopus", - "location": "oyster", - "membership": "nudibranch", - } - path = GkeHubClient.membership_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_membership_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = GkeHubClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = GkeHubClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) - actual = GkeHubClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = GkeHubClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) - actual = GkeHubClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = GkeHubClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project,) - actual = GkeHubClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = GkeHubClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_project_path(path) - assert expected == actual - - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format( - project=project, location=location, - ) - actual = GkeHubClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = GkeHubClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = GkeHubClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/metering_v1alpha/__init__.py b/tests/unit/gapic/metering_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/metering_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py b/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/multiclusteringress_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/servicemesh_v1alpha/__init__.py b/tests/unit/gapic/servicemesh_v1alpha/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/servicemesh_v1alpha/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 61c221b3732863424f0a892d06b4ae6426ebce2f Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 10:51:05 +0000 Subject: [PATCH 5/8] remove v1beta --- docs/configmanagement_v1beta/services.rst | 4 - docs/configmanagement_v1beta/types.rst | 7 - docs/gkehub_v1beta/gke_hub.rst | 10 - docs/gkehub_v1beta/services.rst | 6 - docs/gkehub_v1beta/types.rst | 7 - docs/metering_v1beta/services.rst | 4 - docs/metering_v1beta/types.rst | 7 - docs/multiclusteringress_v1beta/services.rst | 4 - docs/multiclusteringress_v1beta/types.rst | 7 - .../configmanagement_v1beta/__init__.py | 70 - .../gapic_metadata.json | 7 - .../gkehub/configmanagement_v1beta/py.typed | 2 - .../services/__init__.py | 15 - .../configmanagement_v1beta/types/__init__.py | 70 - .../types/configmanagement.py | 575 ----- google/cloud/gkehub/metering/__init__.py | 20 - google/cloud/gkehub/metering/py.typed | 2 - .../cloud/gkehub/metering_v1beta/__init__.py | 20 - .../metering_v1beta/gapic_metadata.json | 7 - google/cloud/gkehub/metering_v1beta/py.typed | 2 - .../metering_v1beta/services/__init__.py | 15 - .../gkehub/metering_v1beta/types/__init__.py | 18 - .../gkehub/metering_v1beta/types/metering.py | 44 - .../multiclusteringress_v1beta/__init__.py | 24 - .../gapic_metadata.json | 7 - .../multiclusteringress_v1beta/py.typed | 2 - .../services/__init__.py | 15 - .../types/__init__.py | 24 - .../types/multiclusteringress.py | 51 - google/cloud/gkehub_v1beta/__init__.py | 52 - .../cloud/gkehub_v1beta/gapic_metadata.json | 73 - google/cloud/gkehub_v1beta/py.typed | 2 - .../cloud/gkehub_v1beta/services/__init__.py | 15 - .../services/gke_hub/__init__.py | 22 - .../services/gke_hub/async_client.py | 634 ----- .../gkehub_v1beta/services/gke_hub/client.py | 827 ------- .../gkehub_v1beta/services/gke_hub/pagers.py | 156 -- .../services/gke_hub/transports/__init__.py | 33 - .../services/gke_hub/transports/base.py | 225 -- .../services/gke_hub/transports/grpc.py | 385 --- .../gke_hub/transports/grpc_asyncio.py | 394 --- google/cloud/gkehub_v1beta/types/__init__.py | 50 - google/cloud/gkehub_v1beta/types/feature.py | 249 -- google/cloud/gkehub_v1beta/types/service.py | 269 -- .../fixup_configmanagement_v1beta_keywords.py | 175 -- scripts/fixup_gkehub_v1beta_keywords.py | 180 -- scripts/fixup_metering_v1beta_keywords.py | 175 -- ...xup_multiclusteringress_v1beta_keywords.py | 175 -- .../gapic/configmanagement_v1beta/__init__.py | 15 - tests/unit/gapic/gkehub_v1beta/__init__.py | 15 - .../unit/gapic/gkehub_v1beta/test_gke_hub.py | 2175 ----------------- tests/unit/gapic/metering_v1beta/__init__.py | 15 - .../multiclusteringress_v1beta/__init__.py | 15 - 53 files changed, 7372 deletions(-) delete mode 100644 docs/configmanagement_v1beta/services.rst delete mode 100644 docs/configmanagement_v1beta/types.rst delete mode 100644 docs/gkehub_v1beta/gke_hub.rst delete mode 100644 docs/gkehub_v1beta/services.rst delete mode 100644 docs/gkehub_v1beta/types.rst delete mode 100644 docs/metering_v1beta/services.rst delete mode 100644 docs/metering_v1beta/types.rst delete mode 100644 docs/multiclusteringress_v1beta/services.rst delete mode 100644 docs/multiclusteringress_v1beta/types.rst delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/py.typed delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/services/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/types/__init__.py delete mode 100644 google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py delete mode 100644 google/cloud/gkehub/metering/__init__.py delete mode 100644 google/cloud/gkehub/metering/py.typed delete mode 100644 google/cloud/gkehub/metering_v1beta/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1beta/gapic_metadata.json delete mode 100644 google/cloud/gkehub/metering_v1beta/py.typed delete mode 100644 google/cloud/gkehub/metering_v1beta/services/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1beta/types/__init__.py delete mode 100644 google/cloud/gkehub/metering_v1beta/types/metering.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/py.typed delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py delete mode 100644 google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py delete mode 100644 google/cloud/gkehub_v1beta/__init__.py delete mode 100644 google/cloud/gkehub_v1beta/gapic_metadata.json delete mode 100644 google/cloud/gkehub_v1beta/py.typed delete mode 100644 google/cloud/gkehub_v1beta/services/__init__.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/__init__.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/async_client.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/client.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/pagers.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py delete mode 100644 google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py delete mode 100644 google/cloud/gkehub_v1beta/types/__init__.py delete mode 100644 google/cloud/gkehub_v1beta/types/feature.py delete mode 100644 google/cloud/gkehub_v1beta/types/service.py delete mode 100644 scripts/fixup_configmanagement_v1beta_keywords.py delete mode 100644 scripts/fixup_gkehub_v1beta_keywords.py delete mode 100644 scripts/fixup_metering_v1beta_keywords.py delete mode 100644 scripts/fixup_multiclusteringress_v1beta_keywords.py delete mode 100644 tests/unit/gapic/configmanagement_v1beta/__init__.py delete mode 100644 tests/unit/gapic/gkehub_v1beta/__init__.py delete mode 100644 tests/unit/gapic/gkehub_v1beta/test_gke_hub.py delete mode 100644 tests/unit/gapic/metering_v1beta/__init__.py delete mode 100644 tests/unit/gapic/multiclusteringress_v1beta/__init__.py diff --git a/docs/configmanagement_v1beta/services.rst b/docs/configmanagement_v1beta/services.rst deleted file mode 100644 index 1fde4d2..0000000 --- a/docs/configmanagement_v1beta/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Configmanagement v1beta API -============================================================ -.. toctree:: - :maxdepth: 2 diff --git a/docs/configmanagement_v1beta/types.rst b/docs/configmanagement_v1beta/types.rst deleted file mode 100644 index a16ad45..0000000 --- a/docs/configmanagement_v1beta/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Configmanagement v1beta API -========================================================= - -.. automodule:: google.cloud.gkehub.configmanagement_v1beta.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/gkehub_v1beta/gke_hub.rst b/docs/gkehub_v1beta/gke_hub.rst deleted file mode 100644 index 1a0098d..0000000 --- a/docs/gkehub_v1beta/gke_hub.rst +++ /dev/null @@ -1,10 +0,0 @@ -GkeHub ------------------------- - -.. automodule:: google.cloud.gkehub_v1beta.services.gke_hub - :members: - :inherited-members: - -.. automodule:: google.cloud.gkehub_v1beta.services.gke_hub.pagers - :members: - :inherited-members: diff --git a/docs/gkehub_v1beta/services.rst b/docs/gkehub_v1beta/services.rst deleted file mode 100644 index e2c6c8b..0000000 --- a/docs/gkehub_v1beta/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Gkehub v1beta API -=========================================== -.. toctree:: - :maxdepth: 2 - - gke_hub diff --git a/docs/gkehub_v1beta/types.rst b/docs/gkehub_v1beta/types.rst deleted file mode 100644 index 35ca39f..0000000 --- a/docs/gkehub_v1beta/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub v1beta API -======================================== - -.. automodule:: google.cloud.gkehub_v1beta.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/metering_v1beta/services.rst b/docs/metering_v1beta/services.rst deleted file mode 100644 index 9067958..0000000 --- a/docs/metering_v1beta/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Metering v1beta API -==================================================== -.. toctree:: - :maxdepth: 2 diff --git a/docs/metering_v1beta/types.rst b/docs/metering_v1beta/types.rst deleted file mode 100644 index c417a12..0000000 --- a/docs/metering_v1beta/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Metering v1beta API -================================================= - -.. automodule:: google.cloud.gkehub.metering_v1beta.types - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/multiclusteringress_v1beta/services.rst b/docs/multiclusteringress_v1beta/services.rst deleted file mode 100644 index 01f8288..0000000 --- a/docs/multiclusteringress_v1beta/services.rst +++ /dev/null @@ -1,4 +0,0 @@ -Services for Google Cloud Gkehub Multiclusteringress v1beta API -=============================================================== -.. toctree:: - :maxdepth: 2 diff --git a/docs/multiclusteringress_v1beta/types.rst b/docs/multiclusteringress_v1beta/types.rst deleted file mode 100644 index b3000cb..0000000 --- a/docs/multiclusteringress_v1beta/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Gkehub Multiclusteringress v1beta API -============================================================ - -.. automodule:: google.cloud.gkehub.multiclusteringress_v1beta.types - :members: - :undoc-members: - :show-inheritance: diff --git a/google/cloud/gkehub/configmanagement_v1beta/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/__init__.py deleted file mode 100644 index 07c8615..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.configmanagement import BinauthzConfig -from .types.configmanagement import BinauthzState -from .types.configmanagement import BinauthzVersion -from .types.configmanagement import ConfigSync -from .types.configmanagement import ConfigSyncDeploymentState -from .types.configmanagement import ConfigSyncState -from .types.configmanagement import ConfigSyncVersion -from .types.configmanagement import ErrorResource -from .types.configmanagement import GatekeeperDeploymentState -from .types.configmanagement import GitConfig -from .types.configmanagement import GroupVersionKind -from .types.configmanagement import HierarchyControllerConfig -from .types.configmanagement import HierarchyControllerDeploymentState -from .types.configmanagement import HierarchyControllerState -from .types.configmanagement import HierarchyControllerVersion -from .types.configmanagement import InstallError -from .types.configmanagement import MembershipSpec -from .types.configmanagement import MembershipState -from .types.configmanagement import OperatorState -from .types.configmanagement import PolicyController -from .types.configmanagement import PolicyControllerState -from .types.configmanagement import PolicyControllerVersion -from .types.configmanagement import SyncError -from .types.configmanagement import SyncState -from .types.configmanagement import DeploymentState - -__all__ = ( - "BinauthzConfig", - "BinauthzState", - "BinauthzVersion", - "ConfigSync", - "ConfigSyncDeploymentState", - "ConfigSyncState", - "ConfigSyncVersion", - "DeploymentState", - "ErrorResource", - "GatekeeperDeploymentState", - "GitConfig", - "GroupVersionKind", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerState", - "HierarchyControllerVersion", - "InstallError", - "MembershipSpec", - "MembershipState", - "OperatorState", - "PolicyController", - "PolicyControllerState", - "PolicyControllerVersion", - "SyncError", - "SyncState", -) diff --git a/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json b/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json deleted file mode 100644 index f5251c4..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.configmanagement_v1beta", - "protoPackage": "google.cloud.gkehub.configmanagement.v1beta", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/configmanagement_v1beta/py.typed b/google/cloud/gkehub/configmanagement_v1beta/py.typed deleted file mode 100644 index 5d21684..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-configmanagement package uses inline types. diff --git a/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py b/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py deleted file mode 100644 index b65646c..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/types/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .configmanagement import ( - BinauthzConfig, - BinauthzState, - BinauthzVersion, - ConfigSync, - ConfigSyncDeploymentState, - ConfigSyncState, - ConfigSyncVersion, - ErrorResource, - GatekeeperDeploymentState, - GitConfig, - GroupVersionKind, - HierarchyControllerConfig, - HierarchyControllerDeploymentState, - HierarchyControllerState, - HierarchyControllerVersion, - InstallError, - MembershipSpec, - MembershipState, - OperatorState, - PolicyController, - PolicyControllerState, - PolicyControllerVersion, - SyncError, - SyncState, - DeploymentState, -) - -__all__ = ( - "BinauthzConfig", - "BinauthzState", - "BinauthzVersion", - "ConfigSync", - "ConfigSyncDeploymentState", - "ConfigSyncState", - "ConfigSyncVersion", - "ErrorResource", - "GatekeeperDeploymentState", - "GitConfig", - "GroupVersionKind", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerState", - "HierarchyControllerVersion", - "InstallError", - "MembershipSpec", - "MembershipState", - "OperatorState", - "PolicyController", - "PolicyControllerState", - "PolicyControllerVersion", - "SyncError", - "SyncState", - "DeploymentState", -) diff --git a/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py deleted file mode 100644 index 1ecbce0..0000000 --- a/google/cloud/gkehub/configmanagement_v1beta/types/configmanagement.py +++ /dev/null @@ -1,575 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.configmanagement.v1beta", - manifest={ - "DeploymentState", - "MembershipState", - "MembershipSpec", - "ConfigSync", - "GitConfig", - "PolicyController", - "BinauthzConfig", - "HierarchyControllerConfig", - "HierarchyControllerDeploymentState", - "HierarchyControllerVersion", - "HierarchyControllerState", - "OperatorState", - "InstallError", - "ConfigSyncState", - "ConfigSyncVersion", - "ConfigSyncDeploymentState", - "SyncState", - "SyncError", - "ErrorResource", - "GroupVersionKind", - "PolicyControllerState", - "PolicyControllerVersion", - "BinauthzState", - "BinauthzVersion", - "GatekeeperDeploymentState", - }, -) - - -class DeploymentState(proto.Enum): - r"""Enum representing the state of an ACM's deployment on a - cluster - """ - DEPLOYMENT_STATE_UNSPECIFIED = 0 - NOT_INSTALLED = 1 - INSTALLED = 2 - ERROR = 3 - - -class MembershipState(proto.Message): - r"""**Anthos Config Management**: State for a single cluster. - Attributes: - cluster_name (str): - The user-defined name for the cluster used by - ClusterSelectors to group clusters together. This should - match Membership's membership_name, unless the user - installed ACM on the cluster manually prior to enabling the - ACM hub feature. Unique within a Anthos Config Management - installation. - membership_spec (google.cloud.gkehub.configmanagement_v1beta.types.MembershipSpec): - Membership configuration in the cluster. This - represents the actual state in the cluster, - while the MembershipSpec in the FeatureSpec - represents the intended state - operator_state (google.cloud.gkehub.configmanagement_v1beta.types.OperatorState): - Current install status of ACM's Operator - config_sync_state (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncState): - Current sync status - policy_controller_state (google.cloud.gkehub.configmanagement_v1beta.types.PolicyControllerState): - PolicyController status - binauthz_state (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzState): - Binauthz status - hierarchy_controller_state (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerState): - Hierarchy Controller status - """ - - cluster_name = proto.Field(proto.STRING, number=1,) - membership_spec = proto.Field(proto.MESSAGE, number=2, message="MembershipSpec",) - operator_state = proto.Field(proto.MESSAGE, number=3, message="OperatorState",) - config_sync_state = proto.Field(proto.MESSAGE, number=4, message="ConfigSyncState",) - policy_controller_state = proto.Field( - proto.MESSAGE, number=5, message="PolicyControllerState", - ) - binauthz_state = proto.Field(proto.MESSAGE, number=6, message="BinauthzState",) - hierarchy_controller_state = proto.Field( - proto.MESSAGE, number=7, message="HierarchyControllerState", - ) - - -class MembershipSpec(proto.Message): - r"""**Anthos Config Management**: Configuration for a single cluster. - Intended to parallel the ConfigManagement CR. - - Attributes: - config_sync (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSync): - Config Sync configuration for the cluster. - policy_controller (google.cloud.gkehub.configmanagement_v1beta.types.PolicyController): - Policy Controller configuration for the - cluster. - binauthz (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzConfig): - Binauthz conifguration for the cluster. - hierarchy_controller (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerConfig): - Hierarchy Controller configuration for the - cluster. - version (str): - Version of ACM installed. - """ - - config_sync = proto.Field(proto.MESSAGE, number=1, message="ConfigSync",) - policy_controller = proto.Field( - proto.MESSAGE, number=2, message="PolicyController", - ) - binauthz = proto.Field(proto.MESSAGE, number=3, message="BinauthzConfig",) - hierarchy_controller = proto.Field( - proto.MESSAGE, number=4, message="HierarchyControllerConfig", - ) - version = proto.Field(proto.STRING, number=10,) - - -class ConfigSync(proto.Message): - r"""Configuration for Config Sync - Attributes: - git (google.cloud.gkehub.configmanagement_v1beta.types.GitConfig): - Git repo configuration for the cluster. - source_format (str): - Specifies whether the Config Sync Repo is - in “hierarchical” or “unstructured” mode. - """ - - git = proto.Field(proto.MESSAGE, number=7, message="GitConfig",) - source_format = proto.Field(proto.STRING, number=8,) - - -class GitConfig(proto.Message): - r"""Git repo configuration for a single cluster. - Attributes: - sync_repo (str): - The URL of the Git repository to use as the - source of truth. - sync_branch (str): - The branch of the repository to sync from. - Default: master. - policy_dir (str): - The path within the Git repository that - represents the top level of the repo to sync. - Default: the root directory of the repository. - sync_wait_secs (int): - Period in seconds between consecutive syncs. - Default: 15. - sync_rev (str): - Git revision (tag or hash) to check out. - Default HEAD. - secret_type (str): - Type of secret configured for access to the - Git repo. - https_proxy (str): - URL for the HTTPS proxy to be used when - communicating with the Git repo. - gcp_service_account_email (str): - The GCP Service Account Email used for auth when secret_type - is gcpServiceAccount. - """ - - sync_repo = proto.Field(proto.STRING, number=1,) - sync_branch = proto.Field(proto.STRING, number=2,) - policy_dir = proto.Field(proto.STRING, number=3,) - sync_wait_secs = proto.Field(proto.INT64, number=4,) - sync_rev = proto.Field(proto.STRING, number=5,) - secret_type = proto.Field(proto.STRING, number=6,) - https_proxy = proto.Field(proto.STRING, number=7,) - gcp_service_account_email = proto.Field(proto.STRING, number=8,) - - -class PolicyController(proto.Message): - r"""Configuration for Policy Controller - Attributes: - enabled (bool): - Enables the installation of Policy - Controller. If false, the rest of - PolicyController fields take no effect. - template_library_installed (bool): - Installs the default template library along - with Policy Controller. - audit_interval_seconds (int): - Sets the interval for Policy Controller Audit - Scans (in seconds). When set to 0, this disables - audit functionality altogether. - exemptable_namespaces (Sequence[str]): - The set of namespaces that are excluded from - Policy Controller checks. Namespaces do not need - to currently exist on the cluster. - referential_rules_enabled (bool): - Enables the ability to use Constraint - Templates that reference to objects other than - the object currently being evaluated. - log_denies_enabled (bool): - Logs all denies and dry run failures. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - template_library_installed = proto.Field(proto.BOOL, number=2, optional=True,) - audit_interval_seconds = proto.Field(proto.INT64, number=3, optional=True,) - exemptable_namespaces = proto.RepeatedField(proto.STRING, number=4,) - referential_rules_enabled = proto.Field(proto.BOOL, number=5,) - log_denies_enabled = proto.Field(proto.BOOL, number=6,) - - -class BinauthzConfig(proto.Message): - r"""Configuration for Binauthz - Attributes: - enabled (bool): - Whether binauthz is enabled in this cluster. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - - -class HierarchyControllerConfig(proto.Message): - r"""Configuration for Hierarchy Controller - Attributes: - enabled (bool): - Whether Hierarchy Controller is enabled in - this cluster. - enable_pod_tree_labels (bool): - Whether pod tree labels are enabled in this - cluster. - enable_hierarchical_resource_quota (bool): - Whether hierarchical resource quota is - enabled in this cluster. - """ - - enabled = proto.Field(proto.BOOL, number=1,) - enable_pod_tree_labels = proto.Field(proto.BOOL, number=2,) - enable_hierarchical_resource_quota = proto.Field(proto.BOOL, number=3,) - - -class HierarchyControllerDeploymentState(proto.Message): - r"""Deployment state for Hierarchy Controller - Attributes: - hnc (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - The deployment state for open source HNC - (e.g. v0.7.0-hc.0) - extension (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - The deployment state for Hierarchy Controller - extension (e.g. v0.7.0-hc.1) - """ - - hnc = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - extension = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - - -class HierarchyControllerVersion(proto.Message): - r"""Version for Hierarchy Controller - Attributes: - hnc (str): - Version for open source HNC - extension (str): - Version for Hierarchy Controller extension - """ - - hnc = proto.Field(proto.STRING, number=1,) - extension = proto.Field(proto.STRING, number=2,) - - -class HierarchyControllerState(proto.Message): - r"""State for Hierarchy Controller - Attributes: - version (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerVersion): - The version for Hierarchy Controller - state (google.cloud.gkehub.configmanagement_v1beta.types.HierarchyControllerDeploymentState): - The deployment state for Hierarchy Controller - """ - - version = proto.Field( - proto.MESSAGE, number=1, message="HierarchyControllerVersion", - ) - state = proto.Field( - proto.MESSAGE, number=2, message="HierarchyControllerDeploymentState", - ) - - -class OperatorState(proto.Message): - r"""State information for an ACM's Operator - Attributes: - version (str): - The semenatic version number of the operator - deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - The state of the Operator's deployment - errors (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.InstallError]): - Install errors. - """ - - version = proto.Field(proto.STRING, number=1,) - deployment_state = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - errors = proto.RepeatedField(proto.MESSAGE, number=3, message="InstallError",) - - -class InstallError(proto.Message): - r"""Errors pertaining to the installation of ACM - Attributes: - error_message (str): - A string representing the user facing error - message - """ - - error_message = proto.Field(proto.STRING, number=1,) - - -class ConfigSyncState(proto.Message): - r"""State information for ConfigSync - Attributes: - version (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncVersion): - The version of ConfigSync deployed - deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.ConfigSyncDeploymentState): - Information about the deployment of - ConfigSync, including the version of the various - Pods deployed - sync_state (google.cloud.gkehub.configmanagement_v1beta.types.SyncState): - The state of ConfigSync's process to sync - configs to a cluster - """ - - version = proto.Field(proto.MESSAGE, number=1, message="ConfigSyncVersion",) - deployment_state = proto.Field( - proto.MESSAGE, number=2, message="ConfigSyncDeploymentState", - ) - sync_state = proto.Field(proto.MESSAGE, number=3, message="SyncState",) - - -class ConfigSyncVersion(proto.Message): - r"""Specific versioning information pertaining to ConfigSync's - Pods - - Attributes: - importer (str): - Version of the deployed importer pod - syncer (str): - Version of the deployed syncer pod - git_sync (str): - Version of the deployed git-sync pod - monitor (str): - Version of the deployed monitor pod - reconciler_manager (str): - Version of the deployed reconciler-manager - pod - root_reconciler (str): - Version of the deployed reconciler container - in root-reconciler pod - """ - - importer = proto.Field(proto.STRING, number=1,) - syncer = proto.Field(proto.STRING, number=2,) - git_sync = proto.Field(proto.STRING, number=3,) - monitor = proto.Field(proto.STRING, number=4,) - reconciler_manager = proto.Field(proto.STRING, number=5,) - root_reconciler = proto.Field(proto.STRING, number=6,) - - -class ConfigSyncDeploymentState(proto.Message): - r"""The state of ConfigSync's deployment on a cluster - Attributes: - importer (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of the importer pod - syncer (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of the syncer pod - git_sync (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of the git-sync pod - monitor (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of the monitor pod - reconciler_manager (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of reconciler-manager pod - root_reconciler (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Deployment state of root-reconciler - """ - - importer = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - syncer = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - git_sync = proto.Field(proto.ENUM, number=3, enum="DeploymentState",) - monitor = proto.Field(proto.ENUM, number=4, enum="DeploymentState",) - reconciler_manager = proto.Field(proto.ENUM, number=5, enum="DeploymentState",) - root_reconciler = proto.Field(proto.ENUM, number=6, enum="DeploymentState",) - - -class SyncState(proto.Message): - r"""State indicating an ACM's progress syncing configurations to - a cluster - - Attributes: - source_token (str): - Token indicating the state of the repo. - import_token (str): - Token indicating the state of the importer. - sync_token (str): - Token indicating the state of the syncer. - last_sync (str): - Deprecated: use last_sync_time instead. Timestamp of when - ACM last successfully synced the repo The time format is - specified in https://golang.org/pkg/time/#Time.String - last_sync_time (google.protobuf.timestamp_pb2.Timestamp): - Timestamp type of when ACM last successfully - synced the repo - code (google.cloud.gkehub.configmanagement_v1beta.types.SyncState.SyncCode): - Sync status code - errors (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.SyncError]): - A list of errors resulting from problematic - configs. This list will be truncated after 100 - errors, although it is unlikely for that many - errors to simultaneously exist. - """ - - class SyncCode(proto.Enum): - r"""An enum representing an ACM's status syncing configs to a - cluster - """ - SYNC_CODE_UNSPECIFIED = 0 - SYNCED = 1 - PENDING = 2 - ERROR = 3 - NOT_CONFIGURED = 4 - NOT_INSTALLED = 5 - UNAUTHORIZED = 6 - UNREACHABLE = 7 - - source_token = proto.Field(proto.STRING, number=1,) - import_token = proto.Field(proto.STRING, number=2,) - sync_token = proto.Field(proto.STRING, number=3,) - last_sync = proto.Field(proto.STRING, number=4,) - last_sync_time = proto.Field( - proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, - ) - code = proto.Field(proto.ENUM, number=5, enum=SyncCode,) - errors = proto.RepeatedField(proto.MESSAGE, number=6, message="SyncError",) - - -class SyncError(proto.Message): - r"""An ACM created error representing a problem syncing - configurations - - Attributes: - code (str): - An ACM defined error code - error_message (str): - A description of the error - error_resources (Sequence[google.cloud.gkehub.configmanagement_v1beta.types.ErrorResource]): - A list of config(s) associated with the - error, if any - """ - - code = proto.Field(proto.STRING, number=1,) - error_message = proto.Field(proto.STRING, number=2,) - error_resources = proto.RepeatedField( - proto.MESSAGE, number=3, message="ErrorResource", - ) - - -class ErrorResource(proto.Message): - r"""Model for a config file in the git repo with an associated - Sync error - - Attributes: - source_path (str): - Path in the git repo of the erroneous config - resource_name (str): - Metadata name of the resource that is causing - an error - resource_namespace (str): - Namespace of the resource that is causing an - error - resource_gvk (google.cloud.gkehub.configmanagement_v1beta.types.GroupVersionKind): - Group/version/kind of the resource that is - causing an error - """ - - source_path = proto.Field(proto.STRING, number=1,) - resource_name = proto.Field(proto.STRING, number=2,) - resource_namespace = proto.Field(proto.STRING, number=3,) - resource_gvk = proto.Field(proto.MESSAGE, number=4, message="GroupVersionKind",) - - -class GroupVersionKind(proto.Message): - r"""A Kubernetes object's GVK - Attributes: - group (str): - Kubernetes Group - version (str): - Kubernetes Version - kind (str): - Kubernetes Kind - """ - - group = proto.Field(proto.STRING, number=1,) - version = proto.Field(proto.STRING, number=2,) - kind = proto.Field(proto.STRING, number=3,) - - -class PolicyControllerState(proto.Message): - r"""State for PolicyControllerState. - Attributes: - version (google.cloud.gkehub.configmanagement_v1beta.types.PolicyControllerVersion): - The version of Gatekeeper Policy Controller - deployed. - deployment_state (google.cloud.gkehub.configmanagement_v1beta.types.GatekeeperDeploymentState): - The state about the policy controller - installation. - """ - - version = proto.Field(proto.MESSAGE, number=1, message="PolicyControllerVersion",) - deployment_state = proto.Field( - proto.MESSAGE, number=2, message="GatekeeperDeploymentState", - ) - - -class PolicyControllerVersion(proto.Message): - r"""The build version of Gatekeeper Policy Controller is using. - Attributes: - version (str): - The gatekeeper image tag that is composed of - ACM version, git tag, build number. - """ - - version = proto.Field(proto.STRING, number=1,) - - -class BinauthzState(proto.Message): - r"""State for Binauthz - Attributes: - webhook (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - The state of the binauthz webhook. - version (google.cloud.gkehub.configmanagement_v1beta.types.BinauthzVersion): - The version of binauthz that is installed. - """ - - webhook = proto.Field(proto.ENUM, number=1, enum="DeploymentState",) - version = proto.Field(proto.MESSAGE, number=2, message="BinauthzVersion",) - - -class BinauthzVersion(proto.Message): - r"""The version of binauthz. - Attributes: - webhook_version (str): - The version of the binauthz webhook. - """ - - webhook_version = proto.Field(proto.STRING, number=1,) - - -class GatekeeperDeploymentState(proto.Message): - r"""State of Policy Controller installation. - Attributes: - gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Status of gatekeeper-controller-manager pod. - gatekeeper_audit (google.cloud.gkehub.configmanagement_v1beta.types.DeploymentState): - Status of gatekeeper-audit deployment. - """ - - gatekeeper_controller_manager_state = proto.Field( - proto.ENUM, number=1, enum="DeploymentState", - ) - gatekeeper_audit = proto.Field(proto.ENUM, number=2, enum="DeploymentState",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/metering/__init__.py b/google/cloud/gkehub/metering/__init__.py deleted file mode 100644 index f84a687..0000000 --- a/google/cloud/gkehub/metering/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub.metering_v1beta.types.metering import MembershipState - -__all__ = ("MembershipState",) diff --git a/google/cloud/gkehub/metering/py.typed b/google/cloud/gkehub/metering/py.typed deleted file mode 100644 index 1947b3f..0000000 --- a/google/cloud/gkehub/metering/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-metering package uses inline types. diff --git a/google/cloud/gkehub/metering_v1beta/__init__.py b/google/cloud/gkehub/metering_v1beta/__init__.py deleted file mode 100644 index 04fad4f..0000000 --- a/google/cloud/gkehub/metering_v1beta/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.metering import MembershipState - -__all__ = ("MembershipState",) diff --git a/google/cloud/gkehub/metering_v1beta/gapic_metadata.json b/google/cloud/gkehub/metering_v1beta/gapic_metadata.json deleted file mode 100644 index f6aa344..0000000 --- a/google/cloud/gkehub/metering_v1beta/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.metering_v1beta", - "protoPackage": "google.cloud.gkehub.metering.v1beta", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/metering_v1beta/py.typed b/google/cloud/gkehub/metering_v1beta/py.typed deleted file mode 100644 index 1947b3f..0000000 --- a/google/cloud/gkehub/metering_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-metering package uses inline types. diff --git a/google/cloud/gkehub/metering_v1beta/services/__init__.py b/google/cloud/gkehub/metering_v1beta/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/metering_v1beta/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/metering_v1beta/types/__init__.py b/google/cloud/gkehub/metering_v1beta/types/__init__.py deleted file mode 100644 index 7cf2c8d..0000000 --- a/google/cloud/gkehub/metering_v1beta/types/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .metering import MembershipState - -__all__ = ("MembershipState",) diff --git a/google/cloud/gkehub/metering_v1beta/types/metering.py b/google/cloud/gkehub/metering_v1beta/types/metering.py deleted file mode 100644 index 538e076..0000000 --- a/google/cloud/gkehub/metering_v1beta/types/metering.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.metering.v1beta", manifest={"MembershipState",}, -) - - -class MembershipState(proto.Message): - r"""**Metering**: Per-Membership Feature State. - Attributes: - last_measurement_time (google.protobuf.timestamp_pb2.Timestamp): - The time stamp of the most recent measurement - of the number of vCPUs in the cluster. - precise_last_measured_cluster_vcpu_capacity (float): - The vCPUs capacity in the cluster according - to the most recent measurement (1/1000 - precision). - """ - - last_measurement_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, - ) - precise_last_measured_cluster_vcpu_capacity = proto.Field(proto.FLOAT, number=3,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py deleted file mode 100644 index 661754d..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .types.multiclusteringress import FeatureSpec -from .types.multiclusteringress import Billing - -__all__ = ( - "Billing", - "FeatureSpec", -) diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json b/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json deleted file mode 100644 index 3b263e7..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/gapic_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub.multiclusteringress_v1beta", - "protoPackage": "google.cloud.gkehub.multiclusteringress.v1beta", - "schema": "1.0" -} diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/py.typed b/google/cloud/gkehub/multiclusteringress_v1beta/py.typed deleted file mode 100644 index 298daf2..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gkehub-multiclusteringress package uses inline types. diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py b/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py deleted file mode 100644 index 29ec9f8..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/types/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .multiclusteringress import ( - FeatureSpec, - Billing, -) - -__all__ = ( - "FeatureSpec", - "Billing", -) diff --git a/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py deleted file mode 100644 index ae90a77..0000000 --- a/google/cloud/gkehub/multiclusteringress_v1beta/types/multiclusteringress.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.multiclusteringress.v1beta", - manifest={"Billing", "FeatureSpec",}, -) - - -class Billing(proto.Enum): - r"""Billing identifies which billing structure the customer is - using. - """ - BILLING_UNSPECIFIED = 0 - PAY_AS_YOU_GO = 1 - ANTHOS_LICENSE = 2 - - -class FeatureSpec(proto.Message): - r"""**Multi-cluster Ingress**: The configuration for the - MultiClusterIngress feature. - - Attributes: - config_membership (str): - Fully-qualified Membership name which hosts the - MultiClusterIngress CRD. Example: - ``projects/foo-proj/locations/global/memberships/bar`` - billing (google.cloud.gkehub.multiclusteringress_v1beta.types.Billing): - Customer's billing structure - """ - - config_membership = proto.Field(proto.STRING, number=1,) - billing = proto.Field(proto.ENUM, number=2, enum="Billing",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1beta/__init__.py b/google/cloud/gkehub_v1beta/__init__.py deleted file mode 100644 index dcb311b..0000000 --- a/google/cloud/gkehub_v1beta/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .services.gke_hub import GkeHubClient -from .services.gke_hub import GkeHubAsyncClient - -from .types.feature import CommonFeatureSpec -from .types.feature import CommonFeatureState -from .types.feature import Feature -from .types.feature import FeatureResourceState -from .types.feature import FeatureState -from .types.feature import MembershipFeatureSpec -from .types.feature import MembershipFeatureState -from .types.service import CreateFeatureRequest -from .types.service import DeleteFeatureRequest -from .types.service import GetFeatureRequest -from .types.service import ListFeaturesRequest -from .types.service import ListFeaturesResponse -from .types.service import OperationMetadata -from .types.service import UpdateFeatureRequest - -__all__ = ( - "GkeHubAsyncClient", - "CommonFeatureSpec", - "CommonFeatureState", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "Feature", - "FeatureResourceState", - "FeatureState", - "GetFeatureRequest", - "GkeHubClient", - "ListFeaturesRequest", - "ListFeaturesResponse", - "MembershipFeatureSpec", - "MembershipFeatureState", - "OperationMetadata", - "UpdateFeatureRequest", -) diff --git a/google/cloud/gkehub_v1beta/gapic_metadata.json b/google/cloud/gkehub_v1beta/gapic_metadata.json deleted file mode 100644 index 18bfdca..0000000 --- a/google/cloud/gkehub_v1beta/gapic_metadata.json +++ /dev/null @@ -1,73 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.gkehub_v1beta", - "protoPackage": "google.cloud.gkehub.v1beta", - "schema": "1.0", - "services": { - "GkeHub": { - "clients": { - "grpc": { - "libraryClient": "GkeHubClient", - "rpcs": { - "CreateFeature": { - "methods": [ - "create_feature" - ] - }, - "DeleteFeature": { - "methods": [ - "delete_feature" - ] - }, - "GetFeature": { - "methods": [ - "get_feature" - ] - }, - "ListFeatures": { - "methods": [ - "list_features" - ] - }, - "UpdateFeature": { - "methods": [ - "update_feature" - ] - } - } - }, - "grpc-async": { - "libraryClient": "GkeHubAsyncClient", - "rpcs": { - "CreateFeature": { - "methods": [ - "create_feature" - ] - }, - "DeleteFeature": { - "methods": [ - "delete_feature" - ] - }, - "GetFeature": { - "methods": [ - "get_feature" - ] - }, - "ListFeatures": { - "methods": [ - "list_features" - ] - }, - "UpdateFeature": { - "methods": [ - "update_feature" - ] - } - } - } - } - } - } -} diff --git a/google/cloud/gkehub_v1beta/py.typed b/google/cloud/gkehub_v1beta/py.typed deleted file mode 100644 index 7a6a6d0..0000000 --- a/google/cloud/gkehub_v1beta/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-gke-hub package uses inline types. diff --git a/google/cloud/gkehub_v1beta/services/__init__.py b/google/cloud/gkehub_v1beta/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/google/cloud/gkehub_v1beta/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py b/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py deleted file mode 100644 index 73e44b4..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .client import GkeHubClient -from .async_client import GkeHubAsyncClient - -__all__ = ( - "GkeHubClient", - "GkeHubAsyncClient", -) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py b/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py deleted file mode 100644 index ad47b41..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/async_client.py +++ /dev/null @@ -1,634 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1beta.services.gke_hub import pagers -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport -from .client import GkeHubClient - - -class GkeHubAsyncClient: - """The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1beta.Membership] - - [Feature][google.cloud.gkehub.v1beta.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - """ - - _client: GkeHubClient - - DEFAULT_ENDPOINT = GkeHubClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = GkeHubClient.DEFAULT_MTLS_ENDPOINT - - feature_path = staticmethod(GkeHubClient.feature_path) - parse_feature_path = staticmethod(GkeHubClient.parse_feature_path) - common_billing_account_path = staticmethod(GkeHubClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod( - GkeHubClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(GkeHubClient.common_folder_path) - parse_common_folder_path = staticmethod(GkeHubClient.parse_common_folder_path) - common_organization_path = staticmethod(GkeHubClient.common_organization_path) - parse_common_organization_path = staticmethod( - GkeHubClient.parse_common_organization_path - ) - common_project_path = staticmethod(GkeHubClient.common_project_path) - parse_common_project_path = staticmethod(GkeHubClient.parse_common_project_path) - common_location_path = staticmethod(GkeHubClient.common_location_path) - parse_common_location_path = staticmethod(GkeHubClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_info.__func__(GkeHubAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubAsyncClient: The constructed client. - """ - return GkeHubClient.from_service_account_file.__func__(GkeHubAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial( - type(GkeHubClient).get_transport_class, type(GkeHubClient) - ) - - def __init__( - self, - *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, GkeHubTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = GkeHubClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - async def list_features( - self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesAsyncPager: - r"""Lists Features in a given project and location. - - Args: - request (:class:`google.cloud.gkehub_v1beta.types.ListFeaturesRequest`): - The request object. Request message for - `GkeHub.ListFeatures` method. - parent (:class:`str`): - The parent (project and location) where the Features - will be listed. Specified in the format - ``projects/*/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.gkehub_v1beta.services.gke_hub.pagers.ListFeaturesAsyncPager: - Response message for the GkeHub.ListFeatures method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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.ListFeaturesRequest(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_features, - 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.ListFeaturesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_feature( - self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: - r"""Gets details of a single Feature. - - Args: - request (:class:`google.cloud.gkehub_v1beta.types.GetFeatureRequest`): - The request object. Request message for - `GkeHub.GetFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - - 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.gkehub_v1beta.types.Feature: - Feature represents the settings and - status of any Hub Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = service.GetFeatureRequest(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_feature, - 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 create_feature( - self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Adds a new Feature. - - Args: - request (:class:`google.cloud.gkehub_v1beta.types.CreateFeatureRequest`): - The request object. Request message for the - `GkeHub.CreateFeature` method. - parent (:class:`str`): - The parent (project and location) where the Feature will - be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1beta.types.Feature`): - The Feature resource to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - feature_id (:class:`str`): - The ID of the feature to create. - This corresponds to the ``feature_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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if feature_id is not None: - request.feature_id = feature_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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_feature( - self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Removes a Feature. - - Args: - request (:class:`google.cloud.gkehub_v1beta.types.DeleteFeatureRequest`): - The request object. Request message for - `GkeHub.DeleteFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = service.DeleteFeatureRequest(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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_feature( - self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates an existing Feature. - - Args: - request (:class:`google.cloud.gkehub_v1beta.types.UpdateFeatureRequest`): - The request object. Request message for - `GkeHub.UpdateFeature` method. - name (:class:`str`): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.gkehub_v1beta.types.Feature`): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. If - you specify the update_mask to be a special path "*", - fully replaces all user-modifiable fields to match - ``resource``. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Mask of fields to update. - 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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.UpdateFeatureRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_feature, - 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,) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubAsyncClient",) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/client.py b/google/cloud/gkehub_v1beta/services/gke_hub/client.py deleted file mode 100644 index 53b4adf..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/client.py +++ /dev/null @@ -1,827 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # 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 - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.gkehub_v1beta.services.gke_hub import pagers -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import GkeHubGrpcTransport -from .transports.grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -class GkeHubClientMeta(type): - """Metaclass for the GkeHub client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - - _transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] - _transport_registry["grpc"] = GkeHubGrpcTransport - _transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - - def get_transport_class(cls, label: str = None,) -> Type[GkeHubTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class GkeHubClient(metaclass=GkeHubClientMeta): - """The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1beta.Membership] - - [Feature][google.cloud.gkehub.v1beta.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "gkehub.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - GkeHubClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> GkeHubTransport: - """Returns the transport used by the client instance. - - Returns: - GkeHubTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def feature_path(project: str, location: str, feature: str,) -> str: - """Returns a fully-qualified feature string.""" - return "projects/{project}/locations/{location}/features/{feature}".format( - project=project, location=location, feature=feature, - ) - - @staticmethod - def parse_feature_path(path: str) -> Dict[str, str]: - """Parses a feature path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/features/(?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, - ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str, str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str,) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str, str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str,) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str, str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str,) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str, str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - 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, - ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str, str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GkeHubTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the gke hub client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, GkeHubTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) - ) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, GkeHubTransport): - # transport is a GkeHubTransport instance. - if credentials or client_options.credentials_file: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def list_features( - self, - request: service.ListFeaturesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFeaturesPager: - r"""Lists Features in a given project and location. - - Args: - request (google.cloud.gkehub_v1beta.types.ListFeaturesRequest): - The request object. Request message for - `GkeHub.ListFeatures` method. - parent (str): - The parent (project and location) where the Features - will be listed. Specified in the format - ``projects/*/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.gkehub_v1beta.services.gke_hub.pagers.ListFeaturesPager: - Response message for the GkeHub.ListFeatures method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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.ListFeaturesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListFeaturesRequest): - request = service.ListFeaturesRequest(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_features] - - # 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.ListFeaturesPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - - # Done; return the response. - return response - - def get_feature( - self, - request: service.GetFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> feature.Feature: - r"""Gets details of a single Feature. - - Args: - request (google.cloud.gkehub_v1beta.types.GetFeatureRequest): - The request object. Request message for - `GkeHub.GetFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - - 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.gkehub_v1beta.types.Feature: - Feature represents the settings and - status of any Hub Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetFeatureRequest): - request = service.GetFeatureRequest(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_feature] - - # 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 create_feature( - self, - request: service.CreateFeatureRequest = None, - *, - parent: str = None, - resource: feature.Feature = None, - feature_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Adds a new Feature. - - Args: - request (google.cloud.gkehub_v1beta.types.CreateFeatureRequest): - The request object. Request message for the - `GkeHub.CreateFeature` method. - parent (str): - The parent (project and location) where the Feature will - be created. Specified in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1beta.types.Feature): - The Feature resource to create. - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - feature_id (str): - The ID of the feature to create. - This corresponds to the ``feature_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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, resource, feature_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.CreateFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateFeatureRequest): - request = service.CreateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if resource is not None: - request.resource = resource - if feature_id is not None: - request.feature_id = feature_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_feature] - - # 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,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_feature( - self, - request: service.DeleteFeatureRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Removes a Feature. - - Args: - request (google.cloud.gkehub_v1beta.types.DeleteFeatureRequest): - The request object. Request message for - `GkeHub.DeleteFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a service.DeleteFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteFeatureRequest): - request = service.DeleteFeatureRequest(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_feature] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_feature( - self, - request: service.UpdateFeatureRequest = None, - *, - name: str = None, - resource: feature.Feature = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates an existing Feature. - - Args: - request (google.cloud.gkehub_v1beta.types.UpdateFeatureRequest): - The request object. Request message for - `GkeHub.UpdateFeature` method. - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.gkehub_v1beta.types.Feature): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are - updating a map field, set the value of a key to null or - empty string to delete the key from the map. It's not - possible to update a key's value to the empty string. If - you specify the update_mask to be a special path "*", - fully replaces all user-modifiable fields to match - ``resource``. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Mask of fields to update. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.gkehub_v1beta.types.Feature` - Feature represents the settings and status of any Hub - Feature. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name, resource, 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.UpdateFeatureRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateFeatureRequest): - request = service.UpdateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if resource is not None: - request.resource = resource - 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_feature] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - feature.Feature, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("GkeHubClient",) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py b/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py deleted file mode 100644 index 39bf42c..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/pagers.py +++ /dev/null @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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, - AsyncIterable, - Awaitable, - Callable, - Iterable, - Sequence, - Tuple, - Optional, -) - -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service - - -class ListFeaturesPager: - """A pager for iterating through ``list_features`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFeatures`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` - 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.ListFeaturesResponse], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - 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.gkehub_v1beta.types.ListFeaturesRequest): - The initial request object. - response (google.cloud.gkehub_v1beta.types.ListFeaturesResponse): - 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.ListFeaturesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListFeaturesResponse]: - 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) -> Iterable[feature.Feature]: - for page in self.pages: - yield from page.resources - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class ListFeaturesAsyncPager: - """A pager for iterating through ``list_features`` requests. - - This class thinly wraps an initial - :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``resources`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFeatures`` requests and continue to iterate - through the ``resources`` field on the - corresponding responses. - - All the usual :class:`google.cloud.gkehub_v1beta.types.ListFeaturesResponse` - 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.ListFeaturesResponse]], - request: service.ListFeaturesRequest, - response: service.ListFeaturesResponse, - *, - 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.gkehub_v1beta.types.ListFeaturesRequest): - The initial request object. - response (google.cloud.gkehub_v1beta.types.ListFeaturesResponse): - 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.ListFeaturesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListFeaturesResponse]: - 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) -> AsyncIterable[feature.Feature]: - async def async_generator(): - async for page in self.pages: - for response in page.resources: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py deleted file mode 100644 index 50e3055..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 collections import OrderedDict -from typing import Dict, Type - -from .base import GkeHubTransport -from .grpc import GkeHubGrpcTransport -from .grpc_asyncio import GkeHubGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[GkeHubTransport]] -_transport_registry["grpc"] = GkeHubGrpcTransport -_transport_registry["grpc_asyncio"] = GkeHubGrpcAsyncIOTransport - -__all__ = ( - "GkeHubTransport", - "GkeHubGrpcTransport", - "GkeHubGrpcAsyncIOTransport", -) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py deleted file mode 100644 index e3a8c15..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/transports/base.py +++ /dev/null @@ -1,225 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-gke-hub",).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class GkeHubTransport(abc.ABC): - """Abstract transport class for GkeHub.""" - - AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) - - DEFAULT_HOST: str = "gkehub.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - 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" - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs( - "'credentials_file' and 'credentials' are mutually exclusive" - ) - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id - ) - - # If the credentials is service account credentials, then always try to use self signed JWT. - if ( - always_use_jwt_access - and isinstance(credentials, service_account.Credentials) - and hasattr(service_account.Credentials, "with_always_use_jwt_access") - ): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_features: gapic_v1.method.wrap_method( - self.list_features, default_timeout=None, client_info=client_info, - ), - self.get_feature: gapic_v1.method.wrap_method( - self.get_feature, default_timeout=None, client_info=client_info, - ), - self.create_feature: gapic_v1.method.wrap_method( - self.create_feature, default_timeout=None, client_info=client_info, - ), - self.delete_feature: gapic_v1.method.wrap_method( - self.delete_feature, default_timeout=None, client_info=client_info, - ), - self.update_feature: gapic_v1.method.wrap_method( - self.update_feature, default_timeout=None, client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_features( - self, - ) -> Callable[ - [service.ListFeaturesRequest], - Union[service.ListFeaturesResponse, Awaitable[service.ListFeaturesResponse]], - ]: - raise NotImplementedError() - - @property - def get_feature( - self, - ) -> Callable[ - [service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]] - ]: - raise NotImplementedError() - - @property - def create_feature( - self, - ) -> Callable[ - [service.CreateFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def delete_feature( - self, - ) -> Callable[ - [service.DeleteFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def update_feature( - self, - ) -> Callable[ - [service.UpdateFeatureRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - -__all__ = ("GkeHubTransport",) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py deleted file mode 100644 index d48007b..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc.py +++ /dev/null @@ -1,385 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO - - -class GkeHubGrpcTransport(GkeHubTransport): - """gRPC backend transport for GkeHub. - - The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1beta.Membership] - - [Feature][google.cloud.gkehub.v1beta.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _stubs: Dict[str, Callable] - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) - - # Return the client from cache. - return self._operations_client - - @property - def list_features( - self, - ) -> Callable[[service.ListFeaturesRequest], service.ListFeaturesResponse]: - r"""Return a callable for the list features method over gRPC. - - Lists Features in a given project and location. - - Returns: - Callable[[~.ListFeaturesRequest], - ~.ListFeaturesResponse]: - 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_features" not in self._stubs: - self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/ListFeatures", - request_serializer=service.ListFeaturesRequest.serialize, - response_deserializer=service.ListFeaturesResponse.deserialize, - ) - return self._stubs["list_features"] - - @property - def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: - r"""Return a callable for the get feature method over gRPC. - - Gets details of a single Feature. - - Returns: - Callable[[~.GetFeatureRequest], - ~.Feature]: - 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_feature" not in self._stubs: - self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/GetFeature", - request_serializer=service.GetFeatureRequest.serialize, - response_deserializer=feature.Feature.deserialize, - ) - return self._stubs["get_feature"] - - @property - def create_feature( - self, - ) -> Callable[[service.CreateFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the create feature method over gRPC. - - Adds a new Feature. - - Returns: - Callable[[~.CreateFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_feature" not in self._stubs: - self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/CreateFeature", - request_serializer=service.CreateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_feature"] - - @property - def delete_feature( - self, - ) -> Callable[[service.DeleteFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the delete feature method over gRPC. - - Removes a Feature. - - Returns: - Callable[[~.DeleteFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_feature" not in self._stubs: - self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature", - request_serializer=service.DeleteFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_feature"] - - @property - def update_feature( - self, - ) -> Callable[[service.UpdateFeatureRequest], operations_pb2.Operation]: - r"""Return a callable for the update feature method over gRPC. - - Updates an existing Feature. - - Returns: - Callable[[~.UpdateFeatureRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_feature" not in self._stubs: - self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature", - request_serializer=service.UpdateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_feature"] - - -__all__ = ("GkeHubGrpcTransport",) diff --git a/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py deleted file mode 100644 index e1f8e03..0000000 --- a/google/cloud/gkehub_v1beta/services/gke_hub/transports/grpc_asyncio.py +++ /dev/null @@ -1,394 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import GkeHubTransport, DEFAULT_CLIENT_INFO -from .grpc import GkeHubGrpcTransport - - -class GkeHubGrpcAsyncIOTransport(GkeHubTransport): - """gRPC AsyncIO backend transport for GkeHub. - - The GKE Hub service handles the registration of many Kubernetes - clusters to Google Cloud, and the management of multi-cluster - features over those clusters. - - The GKE Hub service operates on the following resources: - - - [Membership][google.cloud.gkehub.v1beta.Membership] - - [Feature][google.cloud.gkehub.v1beta.Feature] - - GKE Hub is currently only available in the global region. - - **Membership management may be non-trivial:** it is recommended to - use one of the Google-provided client libraries or tools where - possible when working with Membership resources. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel( - cls, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - def __init__( - self, - *, - host: str = "gkehub.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_features( - self, - ) -> Callable[ - [service.ListFeaturesRequest], Awaitable[service.ListFeaturesResponse] - ]: - r"""Return a callable for the list features method over gRPC. - - Lists Features in a given project and location. - - Returns: - Callable[[~.ListFeaturesRequest], - Awaitable[~.ListFeaturesResponse]]: - 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_features" not in self._stubs: - self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/ListFeatures", - request_serializer=service.ListFeaturesRequest.serialize, - response_deserializer=service.ListFeaturesResponse.deserialize, - ) - return self._stubs["list_features"] - - @property - def get_feature( - self, - ) -> Callable[[service.GetFeatureRequest], Awaitable[feature.Feature]]: - r"""Return a callable for the get feature method over gRPC. - - Gets details of a single Feature. - - Returns: - Callable[[~.GetFeatureRequest], - Awaitable[~.Feature]]: - 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_feature" not in self._stubs: - self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/GetFeature", - request_serializer=service.GetFeatureRequest.serialize, - response_deserializer=feature.Feature.deserialize, - ) - return self._stubs["get_feature"] - - @property - def create_feature( - self, - ) -> Callable[[service.CreateFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create feature method over gRPC. - - Adds a new Feature. - - Returns: - Callable[[~.CreateFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_feature" not in self._stubs: - self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/CreateFeature", - request_serializer=service.CreateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["create_feature"] - - @property - def delete_feature( - self, - ) -> Callable[[service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete feature method over gRPC. - - Removes a Feature. - - Returns: - Callable[[~.DeleteFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_feature" not in self._stubs: - self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/DeleteFeature", - request_serializer=service.DeleteFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["delete_feature"] - - @property - def update_feature( - self, - ) -> Callable[[service.UpdateFeatureRequest], Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update feature method over gRPC. - - Updates an existing Feature. - - Returns: - Callable[[~.UpdateFeatureRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_feature" not in self._stubs: - self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1beta.GkeHub/UpdateFeature", - request_serializer=service.UpdateFeatureRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["update_feature"] - - -__all__ = ("GkeHubGrpcAsyncIOTransport",) diff --git a/google/cloud/gkehub_v1beta/types/__init__.py b/google/cloud/gkehub_v1beta/types/__init__.py deleted file mode 100644 index f966a52..0000000 --- a/google/cloud/gkehub_v1beta/types/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 .feature import ( - CommonFeatureSpec, - CommonFeatureState, - Feature, - FeatureResourceState, - FeatureState, - MembershipFeatureSpec, - MembershipFeatureState, -) -from .service import ( - CreateFeatureRequest, - DeleteFeatureRequest, - GetFeatureRequest, - ListFeaturesRequest, - ListFeaturesResponse, - OperationMetadata, - UpdateFeatureRequest, -) - -__all__ = ( - "CommonFeatureSpec", - "CommonFeatureState", - "Feature", - "FeatureResourceState", - "FeatureState", - "MembershipFeatureSpec", - "MembershipFeatureState", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "GetFeatureRequest", - "ListFeaturesRequest", - "ListFeaturesResponse", - "OperationMetadata", - "UpdateFeatureRequest", -) diff --git a/google/cloud/gkehub_v1beta/types/feature.py b/google/cloud/gkehub_v1beta/types/feature.py deleted file mode 100644 index ea910f4..0000000 --- a/google/cloud/gkehub_v1beta/types/feature.py +++ /dev/null @@ -1,249 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.cloud.gkehub.configmanagement.v1beta import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.metering.v1beta import metering_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1beta import multiclusteringress_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.v1beta", - manifest={ - "Feature", - "FeatureResourceState", - "FeatureState", - "CommonFeatureSpec", - "CommonFeatureState", - "MembershipFeatureSpec", - "MembershipFeatureState", - }, -) - - -class Feature(proto.Message): - r"""Feature represents the settings and status of any Hub - Feature. - - Attributes: - name (str): - Output only. The full, unique name of this Feature resource - in the format ``projects/*/locations/*/features/*``. - labels (Sequence[google.cloud.gkehub_v1beta.types.Feature.LabelsEntry]): - GCP labels for this Feature. - resource_state (google.cloud.gkehub_v1beta.types.FeatureResourceState): - Output only. State of the Feature resource - itself. - spec (google.cloud.gkehub_v1beta.types.CommonFeatureSpec): - Optional. Hub-wide Feature configuration. If - this Feature does not support any Hub-wide - configuration, this field may be unused. - membership_specs (Sequence[google.cloud.gkehub_v1beta.types.Feature.MembershipSpecsEntry]): - Optional. Membership-specific configuration - for this Feature. If this Feature does not - support any per-Membership configuration, this - field may be unused. - The keys indicate which Membership the - configuration is for, in the form: - projects/{p}/locations/{l}/memberships/{m} - Where {p} is the project, {l} is a valid - location and {m} is a valid Membership in this - project at that location. {p} WILL match the - Feature's project. - - {p} will always be returned as the project - number, but the project ID is also accepted - during input. If the same Membership is - specified in the map twice (using the project ID - form, and the project number form), exactly ONE - of the entries will be saved, with no guarantees - as to which. For this reason, it is recommended - the same format be used for all entries when - mutating a Feature. - state (google.cloud.gkehub_v1beta.types.CommonFeatureState): - Output only. The Hub-wide Feature state. - membership_states (Sequence[google.cloud.gkehub_v1beta.types.Feature.MembershipStatesEntry]): - Output only. Membership-specific Feature - status. If this Feature does report any per- - Membership status, this field may be unused. - The keys indicate which Membership the state is - for, in the form: - projects/{p}/locations/{l}/memberships/{m} - Where {p} is the project number, {l} is a valid - location and {m} is a valid Membership in this - project at that location. {p} MUST match the - Feature's project number. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - last updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. When the Feature resource was - deleted. - """ - - name = proto.Field(proto.STRING, number=1,) - labels = proto.MapField(proto.STRING, proto.STRING, number=2,) - resource_state = proto.Field( - proto.MESSAGE, number=3, message="FeatureResourceState", - ) - spec = proto.Field(proto.MESSAGE, number=4, message="CommonFeatureSpec",) - membership_specs = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message="MembershipFeatureSpec", - ) - state = proto.Field(proto.MESSAGE, number=6, message="CommonFeatureState",) - membership_states = proto.MapField( - proto.STRING, proto.MESSAGE, number=7, message="MembershipFeatureState", - ) - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) - delete_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, - ) - - -class FeatureResourceState(proto.Message): - r"""FeatureResourceState describes the state of a Feature *resource* in - the GkeHub API. See ``FeatureState`` for the "running state" of the - Feature in the Hub and across Memberships. - - Attributes: - state (google.cloud.gkehub_v1beta.types.FeatureResourceState.State): - The current state of the Feature resource in - the Hub API. - """ - - class State(proto.Enum): - r"""State describes the lifecycle status of a Feature.""" - STATE_UNSPECIFIED = 0 - ENABLING = 1 - ACTIVE = 2 - DISABLING = 3 - UPDATING = 4 - SERVICE_UPDATING = 5 - - state = proto.Field(proto.ENUM, number=1, enum=State,) - - -class FeatureState(proto.Message): - r"""FeatureState describes the high-level state of a Feature. It - may be used to describe a Feature's state at the environ-level, - or per-membershop, depending on the context. - - Attributes: - code (google.cloud.gkehub_v1beta.types.FeatureState.Code): - The high-level, machine-readable status of - this Feature. - description (str): - A human-readable description of the current - status. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time this status and any related Feature- - pecific details were updated. - """ - - class Code(proto.Enum): - r"""Code represents a machine-readable, high-level status of the - Feature. - """ - CODE_UNSPECIFIED = 0 - OK = 1 - WARNING = 2 - ERROR = 3 - - code = proto.Field(proto.ENUM, number=1, enum=Code,) - description = proto.Field(proto.STRING, number=2,) - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - - -class CommonFeatureSpec(proto.Message): - r"""CommonFeatureSpec contains Hub-wide configuration information - Attributes: - multiclusteringress (google.cloud.gkehub.multiclusteringress.v1beta.multiclusteringress_pb2.FeatureSpec): - Multicluster Ingress-specific spec. - """ - - multiclusteringress = proto.Field( - proto.MESSAGE, - number=102, - oneof="feature_spec", - message=multiclusteringress_pb2.FeatureSpec, - ) - - -class CommonFeatureState(proto.Message): - r"""CommonFeatureState contains Hub-wide Feature status - information. - - Attributes: - state (google.cloud.gkehub_v1beta.types.FeatureState): - Output only. The "running state" of the - Feature in this Hub. - """ - - state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) - - -class MembershipFeatureSpec(proto.Message): - r"""MembershipFeatureSpec contains configuration information for - a single Membership. - - Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1beta.configmanagement_pb2.MembershipSpec): - Config Management-specific spec. - """ - - configmanagement = proto.Field( - proto.MESSAGE, - number=106, - oneof="feature_spec", - message=configmanagement_pb2.MembershipSpec, - ) - - -class MembershipFeatureState(proto.Message): - r"""MembershipFeatureState contains Feature status information - for a single Membership. - - Attributes: - metering (google.cloud.gkehub.metering.v1beta.metering_pb2.MembershipState): - Metering-specific spec. - configmanagement (google.cloud.gkehub.configmanagement.v1beta.configmanagement_pb2.MembershipState): - Config Management-specific state. - state (google.cloud.gkehub_v1beta.types.FeatureState): - The high-level state of this Feature for a - single membership. - """ - - metering = proto.Field( - proto.MESSAGE, - number=104, - oneof="feature_state", - message=metering_pb2.MembershipState, - ) - configmanagement = proto.Field( - proto.MESSAGE, - number=106, - oneof="feature_state", - message=configmanagement_pb2.MembershipState, - ) - state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/gkehub_v1beta/types/service.py b/google/cloud/gkehub_v1beta/types/service.py deleted file mode 100644 index cd21db8..0000000 --- a/google/cloud/gkehub_v1beta/types/service.py +++ /dev/null @@ -1,269 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import proto # type: ignore - -from google.cloud.gkehub_v1beta.types import feature -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package="google.cloud.gkehub.v1beta", - manifest={ - "ListFeaturesRequest", - "ListFeaturesResponse", - "GetFeatureRequest", - "CreateFeatureRequest", - "DeleteFeatureRequest", - "UpdateFeatureRequest", - "OperationMetadata", - }, -) - - -class ListFeaturesRequest(proto.Message): - r"""Request message for ``GkeHub.ListFeatures`` method. - Attributes: - parent (str): - The parent (project and location) where the Features will be - listed. Specified in the format ``projects/*/locations/*``. - page_size (int): - When requesting a 'page' of resources, ``page_size`` - specifies number of resources to return. If unspecified or - set to 0, all resources will be returned. - page_token (str): - Token returned by previous call to ``ListFeatures`` which - specifies the position in the list from where to continue - listing the resources. - filter (str): - Lists Features that match the filter expression, following - the syntax outlined in https://google.aip.dev/160. - - Examples: - - - Feature with the name "servicemesh" in project - "foo-proj": - - name = - "projects/foo-proj/locations/global/features/servicemesh" - - - Features that have a label called ``foo``: - - labels.foo:\* - - - Features that have a label called ``foo`` whose value is - ``bar``: - - labels.foo = bar - order_by (str): - One or more fields to compare and use to sort - the output. See - https://google.aip.dev/132#ordering. - """ - - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) - order_by = proto.Field(proto.STRING, number=5,) - - -class ListFeaturesResponse(proto.Message): - r"""Response message for the ``GkeHub.ListFeatures`` method. - Attributes: - resources (Sequence[google.cloud.gkehub_v1beta.types.Feature]): - The list of matching Features - next_page_token (str): - A token to request the next page of resources from the - ``ListFeatures`` method. The value of an empty string means - that there are no more resources to return. - """ - - @property - def raw_page(self): - return self - - resources = proto.RepeatedField(proto.MESSAGE, number=1, message=feature.Feature,) - next_page_token = proto.Field(proto.STRING, number=2,) - - -class GetFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.GetFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*`` - """ - - name = proto.Field(proto.STRING, number=1,) - - -class CreateFeatureRequest(proto.Message): - r"""Request message for the ``GkeHub.CreateFeature`` method. - Attributes: - parent (str): - The parent (project and location) where the Feature will be - created. Specified in the format ``projects/*/locations/*``. - feature_id (str): - The ID of the feature to create. - resource (google.cloud.gkehub_v1beta.types.Feature): - The Feature resource to create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field(proto.STRING, number=1,) - feature_id = proto.Field(proto.STRING, number=2,) - resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) - request_id = proto.Field(proto.STRING, number=4,) - - -class DeleteFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.DeleteFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - force (bool): - If set to true, the delete will ignore any outstanding - resources for this Feature (that is, - ``FeatureState.has_resources`` is set to true). These - resources will NOT be cleaned up or modified in any way. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - force = proto.Field(proto.BOOL, number=2,) - request_id = proto.Field(proto.STRING, number=3,) - - -class UpdateFeatureRequest(proto.Message): - r"""Request message for ``GkeHub.UpdateFeature`` method. - Attributes: - name (str): - The Feature resource name in the format - ``projects/*/locations/*/features/*``. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Mask of fields to update. - resource (google.cloud.gkehub_v1beta.types.Feature): - Only fields specified in update_mask are updated. If you - specify a field in the update_mask but don't specify its - value here that field will be deleted. If you are updating a - map field, set the value of a key to null or empty string to - delete the key from the map. It's not possible to update a - key's value to the empty string. If you specify the - update_mask to be a special path "*", fully replaces all - user-modifiable fields to match ``resource``. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field(proto.STRING, number=1,) - update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, - ) - resource = proto.Field(proto.MESSAGE, number=3, message=feature.Feature,) - request_id = proto.Field(proto.STRING, number=4,) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_detail (str): - Output only. Human-readable status of the - operation, if any. - cancel_requested (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - target = proto.Field(proto.STRING, number=3,) - verb = proto.Field(proto.STRING, number=4,) - status_detail = proto.Field(proto.STRING, number=5,) - cancel_requested = proto.Field(proto.BOOL, number=6,) - api_version = proto.Field(proto.STRING, number=7,) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_configmanagement_v1beta_keywords.py b/scripts/fixup_configmanagement_v1beta_keywords.py deleted file mode 100644 index b06f1d0..0000000 --- a/scripts/fixup_configmanagement_v1beta_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class configmanagementCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=configmanagementCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the configmanagement client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_gkehub_v1beta_keywords.py b/scripts/fixup_gkehub_v1beta_keywords.py deleted file mode 100644 index fadc530..0000000 --- a/scripts/fixup_gkehub_v1beta_keywords.py +++ /dev/null @@ -1,180 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class gkehubCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_feature': ('parent', 'feature_id', 'resource', 'request_id', ), - 'delete_feature': ('name', 'force', 'request_id', ), - 'get_feature': ('name', ), - 'list_features': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_feature': ('name', 'update_mask', 'resource', 'request_id', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=gkehubCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the gkehub client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_metering_v1beta_keywords.py b/scripts/fixup_metering_v1beta_keywords.py deleted file mode 100644 index 53d00e3..0000000 --- a/scripts/fixup_metering_v1beta_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class meteringCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=meteringCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the metering client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/scripts/fixup_multiclusteringress_v1beta_keywords.py b/scripts/fixup_multiclusteringress_v1beta_keywords.py deleted file mode 100644 index e15ebbc..0000000 --- a/scripts/fixup_multiclusteringress_v1beta_keywords.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class multiclusteringressCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=multiclusteringressCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the multiclusteringress client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/tests/unit/gapic/configmanagement_v1beta/__init__.py b/tests/unit/gapic/configmanagement_v1beta/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/configmanagement_v1beta/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/gkehub_v1beta/__init__.py b/tests/unit/gapic/gkehub_v1beta/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/gkehub_v1beta/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py b/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py deleted file mode 100644 index 3ea9bc7..0000000 --- a/tests/unit/gapic/gkehub_v1beta/test_gke_hub.py +++ /dev/null @@ -1,2175 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -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 operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub.configmanagement.v1beta import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.metering.v1beta import metering_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1beta import multiclusteringress_pb2 # type: ignore -from google.cloud.gkehub_v1beta.services.gke_hub import GkeHubAsyncClient -from google.cloud.gkehub_v1beta.services.gke_hub import GkeHubClient -from google.cloud.gkehub_v1beta.services.gke_hub import pagers -from google.cloud.gkehub_v1beta.services.gke_hub import transports -from google.cloud.gkehub_v1beta.services.gke_hub.transports.base import ( - _GOOGLE_AUTH_VERSION, -) -from google.cloud.gkehub_v1beta.types import feature -from google.cloud.gkehub_v1beta.types import service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return ( - "foo.googleapis.com" - if ("localhost" in client.DEFAULT_ENDPOINT) - else client.DEFAULT_ENDPOINT - ) - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert GkeHubClient._get_default_mtls_endpoint(None) is None - assert GkeHubClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ( - GkeHubClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - GkeHubClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert GkeHubClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_called_with(True) - - -@pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) -def test_gke_hub_client_from_service_account_file(client_class): - 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") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_client_get_transport_class(): - transport = GkeHubClient.get_transport_class() - available_transports = [ - transports.GkeHubGrpcTransport, - ] - assert transport in available_transports - - transport = GkeHubClient.get_transport_class("grpc") - assert transport == transports.GkeHubGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -def test_gke_hub_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(GkeHubClient, "get_transport_class") as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,use_client_cert_env", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "true"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc", "false"), - ( - GkeHubAsyncClient, - transports.GkeHubGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ], -) -@mock.patch.object( - GkeHubClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubClient) -) -@mock.patch.object( - GkeHubAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(GkeHubAsyncClient) -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_gke_hub_client_mtls_env_auto( - client_class, transport_class, transport_name, use_client_cert_env -): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - options = client_options.ClientOptions( - client_cert_source=client_cert_source_callback - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=client_cert_source_callback, - ): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_scopes( - client_class, transport_class, transport_name -): - # Check the case scopes are provided. - 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) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (GkeHubClient, transports.GkeHubGrpcTransport, "grpc"), - (GkeHubAsyncClient, transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_gke_hub_client_client_options_credentials_file( - client_class, transport_class, transport_name -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_gke_hub_client_client_options_from_dict(): - with mock.patch( - "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = GkeHubClient(client_options={"api_endpoint": "squid.clam.whelk"}) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_list_features( - transport: str = "grpc", request_type=service.ListFeaturesRequest -): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse( - next_page_token="next_page_token_value", - ) - response = client.list_features(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.ListFeaturesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == "next_page_token_value" - - -def test_list_features_from_dict(): - test_list_features(request_type=dict) - - -def test_list_features_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 = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - client.list_features() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListFeaturesRequest() - - -@pytest.mark.asyncio -async def test_list_features_async( - transport: str = "grpc_asyncio", request_type=service.ListFeaturesRequest -): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse(next_page_token="next_page_token_value",) - ) - response = await client.list_features(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListFeaturesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_list_features_async_from_dict(): - await test_list_features_async(request_type=dict) - - -def test_list_features_field_headers(): - client = GkeHubClient(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.ListFeaturesRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - call.return_value = service.ListFeaturesResponse() - client.list_features(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_features_field_headers_async(): - client = GkeHubAsyncClient(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.ListFeaturesRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse() - ) - await client.list_features(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_features_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_features(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] - assert args[0].parent == "parent_value" - - -def test_list_features_flattened_error(): - client = GkeHubClient(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_features( - service.ListFeaturesRequest(), parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_features_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListFeaturesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListFeaturesResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_features(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] - assert args[0].parent == "parent_value" - - -@pytest.mark.asyncio -async def test_list_features_flattened_error_async(): - client = GkeHubAsyncClient(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_features( - service.ListFeaturesRequest(), parent="parent_value", - ) - - -def test_list_features_pager(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_features(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, feature.Feature) for i in results) - - -def test_list_features_pages(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_features), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - pages = list(client.list_features(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_features_async_pager(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - async_pager = await client.list_features(request={},) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, feature.Feature) for i in responses) - - -@pytest.mark.asyncio -async def test_list_features_async_pages(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_features), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(), feature.Feature(),], - next_page_token="abc", - ), - service.ListFeaturesResponse(resources=[], next_page_token="def",), - service.ListFeaturesResponse( - resources=[feature.Feature(),], next_page_token="ghi", - ), - service.ListFeaturesResponse( - resources=[feature.Feature(), feature.Feature(),], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_features(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_get_feature(transport: str = "grpc", request_type=service.GetFeatureRequest): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature(name="name_value",) - response = client.get_feature(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.GetFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, feature.Feature) - assert response.name == "name_value" - - -def test_get_feature_from_dict(): - test_get_feature(request_type=dict) - - -def test_get_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.get_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetFeatureRequest() - - -@pytest.mark.asyncio -async def test_get_feature_async( - transport: str = "grpc_asyncio", request_type=service.GetFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - feature.Feature(name="name_value",) - ) - response = await client.get_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, feature.Feature) - assert response.name == "name_value" - - -@pytest.mark.asyncio -async def test_get_feature_async_from_dict(): - await test_get_feature_async(request_type=dict) - - -def test_get_feature_field_headers(): - client = GkeHubClient(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.GetFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - call.return_value = feature.Feature() - client.get_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.GetFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) - await client.get_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_get_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.GetFeatureRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = feature.Feature() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_get_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.GetFeatureRequest(), name="name_value", - ) - - -def test_create_feature( - transport: str = "grpc", request_type=service.CreateFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_feature(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.CreateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_feature_from_dict(): - test_create_feature(request_type=dict) - - -def test_create_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.create_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateFeatureRequest() - - -@pytest.mark.asyncio -async def test_create_feature_async( - transport: str = "grpc_asyncio", request_type=service.CreateFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.create_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_feature_async_from_dict(): - await test_create_feature_async(request_type=dict) - - -def test_create_feature_field_headers(): - client = GkeHubClient(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.CreateFeatureRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.CreateFeatureRequest() - - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.create_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_feature( - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_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] - assert args[0].parent == "parent_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].feature_id == "feature_id_value" - - -def test_create_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.CreateFeatureRequest(), - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_id_value", - ) - - -@pytest.mark.asyncio -async def test_create_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_feature( - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_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] - assert args[0].parent == "parent_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].feature_id == "feature_id_value" - - -@pytest.mark.asyncio -async def test_create_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.CreateFeatureRequest(), - parent="parent_value", - resource=feature.Feature(name="name_value"), - feature_id="feature_id_value", - ) - - -def test_delete_feature( - transport: str = "grpc", request_type=service.DeleteFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_feature(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.DeleteFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_feature_from_dict(): - test_delete_feature(request_type=dict) - - -def test_delete_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.delete_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteFeatureRequest() - - -@pytest.mark.asyncio -async def test_delete_feature_async( - transport: str = "grpc_asyncio", request_type=service.DeleteFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.delete_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_feature_async_from_dict(): - await test_delete_feature_async(request_type=dict) - - -def test_delete_feature_field_headers(): - client = GkeHubClient(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.DeleteFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_feature(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_feature_field_headers_async(): - client = GkeHubAsyncClient(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.DeleteFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_feature(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_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -def test_delete_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.DeleteFeatureRequest(), name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_feature(name="name_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - - -@pytest.mark.asyncio -async def test_delete_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.DeleteFeatureRequest(), name="name_value", - ) - - -def test_update_feature( - transport: str = "grpc", request_type=service.UpdateFeatureRequest -): - client = GkeHubClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_feature(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.UpdateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_feature_from_dict(): - test_update_feature(request_type=dict) - - -def test_update_feature_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 = GkeHubClient( - 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_feature), "__call__") as call: - client.update_feature() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateFeatureRequest() - - -@pytest.mark.asyncio -async def test_update_feature_async( - transport: str = "grpc_asyncio", request_type=service.UpdateFeatureRequest -): - client = GkeHubAsyncClient( - 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_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.update_feature(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateFeatureRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_feature_async_from_dict(): - await test_update_feature_async(request_type=dict) - - -def test_update_feature_field_headers(): - client = GkeHubClient(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.UpdateFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_feature(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_update_feature_field_headers_async(): - client = GkeHubAsyncClient(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.UpdateFeatureRequest() - - request.name = "name/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.update_feature(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_update_feature_flattened(): - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_feature( - name="name_value", - resource=feature.Feature(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] - assert args[0].name == "name_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -def test_update_feature_flattened_error(): - client = GkeHubClient(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_feature( - service.UpdateFeatureRequest(), - name="name_value", - resource=feature.Feature(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -@pytest.mark.asyncio -async def test_update_feature_flattened_async(): - client = GkeHubAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_feature), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_feature( - name="name_value", - resource=feature.Feature(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] - assert args[0].name == "name_value" - assert args[0].resource == feature.Feature(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - - -@pytest.mark.asyncio -async def test_update_feature_flattened_error_async(): - client = GkeHubAsyncClient(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_feature( - service.UpdateFeatureRequest(), - name="name_value", - resource=feature.Feature(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.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = GkeHubClient( - client_options={"scopes": ["1", "2"]}, transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = GkeHubClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.GkeHubGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.GkeHubGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -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() - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = GkeHubClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.GkeHubGrpcTransport,) - - -def test_gke_hub_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_gke_hub_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.GkeHubTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "list_features", - "get_feature", - "create_feature", - "delete_feature", - "update_feature", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_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( - "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_base_transport_with_credentials_file_old_google_auth(): - # 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( - "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -def test_gke_hub_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.cloud.gkehub_v1beta.services.gke_hub.transports.GkeHubTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.GkeHubTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_gke_hub_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_gke_hub_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - GkeHubClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_gte_1_25_0 -def test_gke_hub_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_gke_hub_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.GkeHubGrpcTransport, grpc_helpers), - (transports.GkeHubGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_gke_hub_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "gkehub.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=("https://www.googleapis.com/auth/cloud-platform",), - scopes=["1", "2"], - default_host="gkehub.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds, - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback, - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, private_key=expected_key - ) - - -def test_gke_hub_host_no_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:443" - - -def test_gke_hub_host_with_port(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="gkehub.googleapis.com:8000" - ), - ) - assert client.transport._host == "gkehub.googleapis.com:8000" - - -def test_gke_hub_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_gke_hub_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.GkeHubGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_client_cert_source(transport_class): - with mock.patch( - "grpc.ssl_channel_credentials", autospec=True - ) as grpc_ssl_channel_cred: - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [transports.GkeHubGrpcTransport, transports.GkeHubGrpcAsyncIOTransport], -) -def test_gke_hub_transport_channel_mtls_with_adc(transport_class): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_gke_hub_grpc_lro_client(): - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_gke_hub_grpc_lro_async_client(): - client = GkeHubAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_feature_path(): - project = "squid" - location = "clam" - feature = "whelk" - expected = "projects/{project}/locations/{location}/features/{feature}".format( - project=project, location=location, feature=feature, - ) - actual = GkeHubClient.feature_path(project, location, feature) - assert expected == actual - - -def test_parse_feature_path(): - expected = { - "project": "octopus", - "location": "oyster", - "feature": "nudibranch", - } - path = GkeHubClient.feature_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_feature_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = GkeHubClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = GkeHubClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) - actual = GkeHubClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = GkeHubClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) - actual = GkeHubClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = GkeHubClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project,) - actual = GkeHubClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = GkeHubClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_project_path(path) - assert expected == actual - - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format( - project=project, location=location, - ) - actual = GkeHubClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = GkeHubClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = GkeHubClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - client = GkeHubClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.GkeHubTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = GkeHubClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/metering_v1beta/__init__.py b/tests/unit/gapic/metering_v1beta/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/metering_v1beta/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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. -# diff --git a/tests/unit/gapic/multiclusteringress_v1beta/__init__.py b/tests/unit/gapic/multiclusteringress_v1beta/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/tests/unit/gapic/multiclusteringress_v1beta/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 40229292c4c7a756ffb62a81799a0a0d3a34e4b1 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 11:14:54 +0000 Subject: [PATCH 6/8] add workaround in owlbot.py --- .coveragerc | 2 +- docs/index.rst | 13 +++ google/cloud/gkehub/__init__.py | 102 +++++++++--------- .../cloud/gkehub/configmanagement/__init__.py | 64 ++++------- .../types/configmanagement.py | 40 ++++--- .../gkehub/multiclusteringress/__init__.py | 10 +- .../types/multiclusteringress.py | 2 +- .../services/gke_hub/transports/grpc.py | 5 +- .../gke_hub/transports/grpc_asyncio.py | 5 +- google/cloud/gkehub_v1/types/feature.py | 11 +- google/cloud/gkehub_v1/types/membership.py | 5 +- google/cloud/gkehub_v1/types/service.py | 14 +++ owlbot.py | 46 +++++++- tests/unit/gapic/gkehub_v1/test_gke_hub.py | 24 ++++- 14 files changed, 217 insertions(+), 126 deletions(-) diff --git a/.coveragerc b/.coveragerc index 2b3ad0f..3cef77b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,7 +4,7 @@ branch = True [report] show_missing = True omit = - google/cloud/gkehub/__init__.py + google/cloud/gkehub/multiclusteringress/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER diff --git a/docs/index.rst b/docs/index.rst index 04d2ea9..58d3d03 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,6 +2,18 @@ .. include:: multiprocessing.rst +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + gkehub_v1/services + gkehub_v1/types + configmanagement_v1/services + configmanagement_v1/types + multiclusteringress_v1/services + multiclusteringress_v1/types + API Reference ------------- .. toctree:: @@ -10,6 +22,7 @@ API Reference gkehub_v1beta1/services gkehub_v1beta1/types + Changelog --------- diff --git a/google/cloud/gkehub/__init__.py b/google/cloud/gkehub/__init__.py index 39cf698..3faab2a 100644 --- a/google/cloud/gkehub/__init__.py +++ b/google/cloud/gkehub/__init__.py @@ -14,69 +14,71 @@ # limitations under the License. # -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.client import ( - GkeHubMembershipServiceClient, -) -from google.cloud.gkehub_v1beta1.services.gke_hub_membership_service.async_client import ( - GkeHubMembershipServiceAsyncClient, -) +from google.cloud.gkehub_v1.services.gke_hub.client import GkeHubClient +from google.cloud.gkehub_v1.services.gke_hub.async_client import GkeHubAsyncClient -from google.cloud.gkehub_v1beta1.types.membership import Authority -from google.cloud.gkehub_v1beta1.types.membership import ConnectAgent -from google.cloud.gkehub_v1beta1.types.membership import ConnectAgentResource -from google.cloud.gkehub_v1beta1.types.membership import CreateMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import DeleteMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestRequest -from google.cloud.gkehub_v1beta1.types.membership import GenerateConnectManifestResponse -from google.cloud.gkehub_v1beta1.types.membership import ( - GenerateExclusivityManifestRequest, -) -from google.cloud.gkehub_v1beta1.types.membership import ( - GenerateExclusivityManifestResponse, -) -from google.cloud.gkehub_v1beta1.types.membership import GetMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import GkeCluster -from google.cloud.gkehub_v1beta1.types.membership import KubernetesMetadata -from google.cloud.gkehub_v1beta1.types.membership import KubernetesResource -from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsRequest -from google.cloud.gkehub_v1beta1.types.membership import ListMembershipsResponse -from google.cloud.gkehub_v1beta1.types.membership import Membership -from google.cloud.gkehub_v1beta1.types.membership import MembershipEndpoint -from google.cloud.gkehub_v1beta1.types.membership import MembershipState -from google.cloud.gkehub_v1beta1.types.membership import OperationMetadata -from google.cloud.gkehub_v1beta1.types.membership import ResourceManifest -from google.cloud.gkehub_v1beta1.types.membership import ResourceOptions -from google.cloud.gkehub_v1beta1.types.membership import TypeMeta -from google.cloud.gkehub_v1beta1.types.membership import UpdateMembershipRequest -from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityRequest -from google.cloud.gkehub_v1beta1.types.membership import ValidateExclusivityResponse +from google.cloud.gkehub_v1.types.feature import CommonFeatureSpec +from google.cloud.gkehub_v1.types.feature import CommonFeatureState +from google.cloud.gkehub_v1.types.feature import Feature +from google.cloud.gkehub_v1.types.feature import FeatureResourceState +from google.cloud.gkehub_v1.types.feature import FeatureState +from google.cloud.gkehub_v1.types.feature import MembershipFeatureSpec +from google.cloud.gkehub_v1.types.feature import MembershipFeatureState +from google.cloud.gkehub_v1.types.membership import Authority +from google.cloud.gkehub_v1.types.membership import GkeCluster +from google.cloud.gkehub_v1.types.membership import KubernetesMetadata +from google.cloud.gkehub_v1.types.membership import Membership +from google.cloud.gkehub_v1.types.membership import MembershipEndpoint +from google.cloud.gkehub_v1.types.membership import MembershipState +from google.cloud.gkehub_v1.types.service import ConnectAgentResource +from google.cloud.gkehub_v1.types.service import CreateFeatureRequest +from google.cloud.gkehub_v1.types.service import CreateMembershipRequest +from google.cloud.gkehub_v1.types.service import DeleteFeatureRequest +from google.cloud.gkehub_v1.types.service import DeleteMembershipRequest +from google.cloud.gkehub_v1.types.service import GenerateConnectManifestRequest +from google.cloud.gkehub_v1.types.service import GenerateConnectManifestResponse +from google.cloud.gkehub_v1.types.service import GetFeatureRequest +from google.cloud.gkehub_v1.types.service import GetMembershipRequest +from google.cloud.gkehub_v1.types.service import ListFeaturesRequest +from google.cloud.gkehub_v1.types.service import ListFeaturesResponse +from google.cloud.gkehub_v1.types.service import ListMembershipsRequest +from google.cloud.gkehub_v1.types.service import ListMembershipsResponse +from google.cloud.gkehub_v1.types.service import OperationMetadata +from google.cloud.gkehub_v1.types.service import TypeMeta +from google.cloud.gkehub_v1.types.service import UpdateFeatureRequest +from google.cloud.gkehub_v1.types.service import UpdateMembershipRequest __all__ = ( - "GkeHubMembershipServiceClient", - "GkeHubMembershipServiceAsyncClient", + "GkeHubClient", + "GkeHubAsyncClient", + "CommonFeatureSpec", + "CommonFeatureState", + "Feature", + "FeatureResourceState", + "FeatureState", + "MembershipFeatureSpec", + "MembershipFeatureState", "Authority", - "ConnectAgent", + "GkeCluster", + "KubernetesMetadata", + "Membership", + "MembershipEndpoint", + "MembershipState", "ConnectAgentResource", + "CreateFeatureRequest", "CreateMembershipRequest", + "DeleteFeatureRequest", "DeleteMembershipRequest", "GenerateConnectManifestRequest", "GenerateConnectManifestResponse", - "GenerateExclusivityManifestRequest", - "GenerateExclusivityManifestResponse", + "GetFeatureRequest", "GetMembershipRequest", - "GkeCluster", - "KubernetesMetadata", - "KubernetesResource", + "ListFeaturesRequest", + "ListFeaturesResponse", "ListMembershipsRequest", "ListMembershipsResponse", - "Membership", - "MembershipEndpoint", - "MembershipState", "OperationMetadata", - "ResourceManifest", - "ResourceOptions", "TypeMeta", + "UpdateFeatureRequest", "UpdateMembershipRequest", - "ValidateExclusivityRequest", - "ValidateExclusivityResponse", ) diff --git a/google/cloud/gkehub/configmanagement/__init__.py b/google/cloud/gkehub/configmanagement/__init__.py index 52879c2..f170446 100644 --- a/google/cloud/gkehub/configmanagement/__init__.py +++ b/google/cloud/gkehub/configmanagement/__init__.py @@ -15,80 +15,60 @@ # -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - BinauthzConfig, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - BinauthzState, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - BinauthzVersion, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - ConfigSync, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ConfigSync +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( ConfigSyncDeploymentState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( ConfigSyncState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( ConfigSyncVersion, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - ErrorResource, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ErrorResource +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( GatekeeperDeploymentState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import GitConfig -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import GitConfig +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( GroupVersionKind, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( HierarchyControllerConfig, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( HierarchyControllerDeploymentState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( HierarchyControllerState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( HierarchyControllerVersion, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - InstallError, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import InstallError +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( MembershipSpec, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( MembershipState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( - OperatorState, -) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import OperatorState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( PolicyController, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( PolicyControllerState, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( PolicyControllerVersion, ) -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncError -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import SyncState -from google.cloud.gkehub.configmanagement_v1beta.types.configmanagement import ( +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncError +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import SyncState +from google.cloud.gkehub.configmanagement_v1.types.configmanagement import ( DeploymentState, ) __all__ = ( - "BinauthzConfig", - "BinauthzState", - "BinauthzVersion", "ConfigSync", "ConfigSyncDeploymentState", "ConfigSyncState", diff --git a/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py b/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py index 148af42..2e80137 100644 --- a/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py +++ b/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py @@ -19,7 +19,7 @@ __protobuf__ = proto.module( - package="google.cloud.gkehub.configmanagement.v1", + package="google.cloud.gkehub.configmanagement_v1", manifest={ "DeploymentState", "MembershipState", @@ -59,6 +59,7 @@ class DeploymentState(proto.Enum): class MembershipState(proto.Message): r"""**Anthos Config Management**: State for a single cluster. + Attributes: cluster_name (str): The user-defined name for the cluster used by @@ -122,7 +123,8 @@ class MembershipSpec(proto.Message): class ConfigSync(proto.Message): - r"""Configuration for Config Sync + r"""Configuration for Config Syn. + Attributes: git (google.cloud.gkehub.configmanagement_v1.types.GitConfig): Git repo configuration for the cluster. @@ -137,6 +139,7 @@ class ConfigSync(proto.Message): class GitConfig(proto.Message): r"""Git repo configuration for a single cluster. + Attributes: sync_repo (str): The URL of the Git repository to use as the @@ -176,7 +179,8 @@ class GitConfig(proto.Message): class PolicyController(proto.Message): - r"""Configuration for Policy Controller + r"""Configuration for Policy Controlle. + Attributes: enabled (bool): Enables the installation of Policy @@ -210,7 +214,8 @@ class PolicyController(proto.Message): class HierarchyControllerConfig(proto.Message): - r"""Configuration for Hierarchy Controller + r"""Configuration for Hierarchy Controlle. + Attributes: enabled (bool): Whether Hierarchy Controller is enabled in @@ -229,7 +234,8 @@ class HierarchyControllerConfig(proto.Message): class HierarchyControllerDeploymentState(proto.Message): - r"""Deployment state for Hierarchy Controller + r"""Deployment state for Hierarchy Controlle. + Attributes: hnc (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): The deployment state for open source HNC @@ -244,7 +250,8 @@ class HierarchyControllerDeploymentState(proto.Message): class HierarchyControllerVersion(proto.Message): - r"""Version for Hierarchy Controller + r"""Version for Hierarchy Controlle. + Attributes: hnc (str): Version for open source HNC @@ -257,7 +264,8 @@ class HierarchyControllerVersion(proto.Message): class HierarchyControllerState(proto.Message): - r"""State for Hierarchy Controller + r"""State for Hierarchy Controlle. + Attributes: version (google.cloud.gkehub.configmanagement_v1.types.HierarchyControllerVersion): The version for Hierarchy Controller @@ -274,7 +282,8 @@ class HierarchyControllerState(proto.Message): class OperatorState(proto.Message): - r"""State information for an ACM's Operator + r"""State information for an ACM's Operato. + Attributes: version (str): The semenatic version number of the operator @@ -290,7 +299,8 @@ class OperatorState(proto.Message): class InstallError(proto.Message): - r"""Errors pertaining to the installation of ACM + r"""Errors pertaining to the installation of AC. + Attributes: error_message (str): A string representing the user facing error @@ -301,7 +311,8 @@ class InstallError(proto.Message): class ConfigSyncState(proto.Message): - r"""State information for ConfigSync + r"""State information for ConfigSyn. + Attributes: version (google.cloud.gkehub.configmanagement_v1.types.ConfigSyncVersion): The version of ConfigSync deployed @@ -351,7 +362,8 @@ class ConfigSyncVersion(proto.Message): class ConfigSyncDeploymentState(proto.Message): - r"""The state of ConfigSync's deployment on a cluster + r"""The state of ConfigSync's deployment on a cluste. + Attributes: importer (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): Deployment state of the importer pod @@ -472,7 +484,8 @@ class ErrorResource(proto.Message): class GroupVersionKind(proto.Message): - r"""A Kubernetes object's GVK + r"""A Kubernetes object's GV. + Attributes: group (str): Kubernetes Group @@ -489,6 +502,7 @@ class GroupVersionKind(proto.Message): class PolicyControllerState(proto.Message): r"""State for PolicyControllerState. + Attributes: version (google.cloud.gkehub.configmanagement_v1.types.PolicyControllerVersion): The version of Gatekeeper Policy Controller @@ -506,6 +520,7 @@ class PolicyControllerState(proto.Message): class PolicyControllerVersion(proto.Message): r"""The build version of Gatekeeper Policy Controller is using. + Attributes: version (str): The gatekeeper image tag that is composed of @@ -517,6 +532,7 @@ class PolicyControllerVersion(proto.Message): class GatekeeperDeploymentState(proto.Message): r"""State of Policy Controller installation. + Attributes: gatekeeper_controller_manager_state (google.cloud.gkehub.configmanagement_v1.types.DeploymentState): Status of gatekeeper-controller-manager pod. diff --git a/google/cloud/gkehub/multiclusteringress/__init__.py b/google/cloud/gkehub/multiclusteringress/__init__.py index d9ed69d..a05e215 100644 --- a/google/cloud/gkehub/multiclusteringress/__init__.py +++ b/google/cloud/gkehub/multiclusteringress/__init__.py @@ -15,14 +15,8 @@ # -from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import ( +from google.cloud.gkehub.multiclusteringress_v1.types.multiclusteringress import ( FeatureSpec, ) -from google.cloud.gkehub.multiclusteringress_v1beta.types.multiclusteringress import ( - Billing, -) -__all__ = ( - "FeatureSpec", - "Billing", -) +__all__ = ("FeatureSpec",) diff --git a/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py b/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py index 740be66..ef30a0b 100644 --- a/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py +++ b/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py @@ -17,7 +17,7 @@ __protobuf__ = proto.module( - package="google.cloud.gkehub.multiclusteringress.v1", manifest={"FeatureSpec",}, + package="google.cloud.gkehub.multiclusteringress_v1", manifest={"FeatureSpec",}, ) diff --git a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py index 2b0dc56..0d1dff5 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py @@ -74,6 +74,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -114,6 +115,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -167,7 +170,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py index 89cdc7e..2b75938 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py @@ -120,6 +120,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -161,6 +162,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -213,7 +216,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/gkehub_v1/types/feature.py b/google/cloud/gkehub_v1/types/feature.py index f37caad..0f88891 100644 --- a/google/cloud/gkehub_v1/types/feature.py +++ b/google/cloud/gkehub_v1/types/feature.py @@ -15,8 +15,8 @@ # import proto # type: ignore -from google.cloud.gkehub.configmanagement.v1 import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1 import multiclusteringress_pb2 # type: ignore +import google.cloud.gkehub.configmanagement_v1 as configmanagement_pb2 # type: ignore +import google.cloud.gkehub.multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -58,7 +58,7 @@ class Feature(proto.Message): field may be unused. The keys indicate which Membership the configuration is for, in the form: - projects/{p}/locations/{l}/memberships/{m} + `projects/{p}/locations/{l}/memberships/{m}` Where {p} is the project, {l} is a valid location and {m} is a valid Membership in this project at that location. {p} WILL match the @@ -81,7 +81,7 @@ class Feature(proto.Message): Membership status, this field may be unused. The keys indicate which Membership the state is for, in the form: - projects/{p}/locations/{l}/memberships/{m} + `projects/{p}/locations/{l}/memberships/{m}` Where {p} is the project number, {l} is a valid location and {m} is a valid Membership in this project at that location. {p} MUST match the @@ -172,7 +172,8 @@ class Code(proto.Enum): class CommonFeatureSpec(proto.Message): - r"""CommonFeatureSpec contains Hub-wide configuration information + r"""CommonFeatureSpec contains Hub-wide configuration informatio. + Attributes: multiclusteringress (google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2.FeatureSpec): Multicluster Ingress-specific spec. diff --git a/google/cloud/gkehub_v1/types/membership.py b/google/cloud/gkehub_v1/types/membership.py index 724751d..f1ea88d 100644 --- a/google/cloud/gkehub_v1/types/membership.py +++ b/google/cloud/gkehub_v1/types/membership.py @@ -33,6 +33,7 @@ class Membership(proto.Message): r"""Membership contains information about a member cluster. + Attributes: endpoint (google.cloud.gkehub_v1.types.MembershipEndpoint): Optional. Endpoint information to reach this @@ -143,11 +144,12 @@ class MembershipEndpoint(proto.Message): class GkeCluster(proto.Message): r"""GkeCluster contains information specific to GKE clusters. + Attributes: resource_link (str): Immutable. Self-link of the GCP resource for the GKE cluster. For example: - //container.googleapis.com/projects/my- + //container.googleapis.com/projects/my- project/locations/us-west1-a/clusters/my-cluster Zonal clusters are also supported. """ @@ -198,6 +200,7 @@ class KubernetesMetadata(proto.Message): class MembershipState(proto.Message): r"""MembershipState describes the state of a Membership resource. + Attributes: code (google.cloud.gkehub_v1.types.MembershipState.Code): Output only. The current state of the diff --git a/google/cloud/gkehub_v1/types/service.py b/google/cloud/gkehub_v1/types/service.py index 6fcd1ff..d0aec24 100644 --- a/google/cloud/gkehub_v1/types/service.py +++ b/google/cloud/gkehub_v1/types/service.py @@ -47,6 +47,7 @@ class ListMembershipsRequest(proto.Message): r"""Request message for ``GkeHub.ListMemberships`` method. + Attributes: parent (str): Required. The parent (project and location) where the @@ -100,6 +101,7 @@ class ListMembershipsRequest(proto.Message): class ListMembershipsResponse(proto.Message): r"""Response message for the ``GkeHub.ListMemberships`` method. + Attributes: resources (Sequence[google.cloud.gkehub_v1.types.Membership]): The list of matching Memberships. @@ -125,6 +127,7 @@ def raw_page(self): class GetMembershipRequest(proto.Message): r"""Request message for ``GkeHub.GetMembership`` method. + Attributes: name (str): Required. The Membership resource name in the format @@ -136,6 +139,7 @@ class GetMembershipRequest(proto.Message): class CreateMembershipRequest(proto.Message): r"""Request message for the ``GkeHub.CreateMembership`` method. + Attributes: parent (str): Required. The parent (project and location) where the @@ -184,6 +188,7 @@ class CreateMembershipRequest(proto.Message): class DeleteMembershipRequest(proto.Message): r"""Request message for ``GkeHub.DeleteMembership`` method. + Attributes: name (str): Required. The Membership resource name in the format @@ -214,6 +219,7 @@ class DeleteMembershipRequest(proto.Message): class UpdateMembershipRequest(proto.Message): r"""Request message for ``GkeHub.UpdateMembership`` method. + Attributes: name (str): Required. The Membership resource name in the format @@ -259,6 +265,7 @@ class UpdateMembershipRequest(proto.Message): class GenerateConnectManifestRequest(proto.Message): r"""Request message for ``GkeHub.GenerateConnectManifest`` method. . + Attributes: name (str): Required. The Membership resource name the Agent will @@ -350,6 +357,7 @@ class TypeMeta(proto.Message): class ListFeaturesRequest(proto.Message): r"""Request message for ``GkeHub.ListFeatures`` method. + Attributes: parent (str): The parent (project and location) where the Features will be @@ -397,6 +405,7 @@ class ListFeaturesRequest(proto.Message): class ListFeaturesResponse(proto.Message): r"""Response message for the ``GkeHub.ListFeatures`` method. + Attributes: resources (Sequence[google.cloud.gkehub_v1.types.Feature]): The list of matching Features @@ -416,6 +425,7 @@ def raw_page(self): class GetFeatureRequest(proto.Message): r"""Request message for ``GkeHub.GetFeature`` method. + Attributes: name (str): The Feature resource name in the format @@ -427,6 +437,7 @@ class GetFeatureRequest(proto.Message): class CreateFeatureRequest(proto.Message): r"""Request message for the ``GkeHub.CreateFeature`` method. + Attributes: parent (str): The parent (project and location) where the Feature will be @@ -463,6 +474,7 @@ class CreateFeatureRequest(proto.Message): class DeleteFeatureRequest(proto.Message): r"""Request message for ``GkeHub.DeleteFeature`` method. + Attributes: name (str): The Feature resource name in the format @@ -499,6 +511,7 @@ class DeleteFeatureRequest(proto.Message): class UpdateFeatureRequest(proto.Message): r"""Request message for ``GkeHub.UpdateFeature`` method. + Attributes: name (str): The Feature resource name in the format @@ -544,6 +557,7 @@ class UpdateFeatureRequest(proto.Message): class OperationMetadata(proto.Message): r"""Represents the metadata of the long-running operation. + Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the operation was diff --git a/owlbot.py b/owlbot.py index 30544fa..acb4962 100644 --- a/owlbot.py +++ b/owlbot.py @@ -22,9 +22,53 @@ common = gcp.CommonTemplates() -default_version = "v1beta1" +default_version = "v1" for library in s.get_staging_dirs(default_version): + dependencies = [ + "configmanagement", + "multiclusteringress", + ] + + for dep in dependencies: + s.replace( + [ + library / f"google/cloud/gkehub_{library.name}/**/*.py", + library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py", + ], + f"from google.cloud.gkehub.{dep}.{library.name} import", + f"import google.cloud.gkehub.{dep}_{library.name} as" + ) + + s.replace( + [ + library / f"google/cloud/gkehub/{dep}_{library.name}/**/*.py", + ], + f"google.cloud.gkehub.{dep}.{library.name}", + f"google.cloud.gkehub.{dep}_{library.name}" + ) + + # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902 + s.replace(library / f"google/cloud/**/types/*.py", + r""". + Attributes:""", + r""".\n + Attributes:""", + ) + + # Work around docs issue. Fix proposed upstream in cl/382492769 + s.replace(library / f"google/cloud/gkehub_{library.name}/types/feature.py", + " projects/{p}/locations/{l}/memberships/{m}", + "`projects/{p}/locations/{l}/memberships/{m}`" + ) + + # Work around docs issue. Fix proposed upstream in cl/382492769 + s.replace(library / f"google/cloud/gkehub_{library.name}/types/membership.py", + """the GKE cluster. For example: + //container.googleapis.com/projects/my-""", + """the GKE cluster. For example: + //container.googleapis.com/projects/my-""" + ) s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) s.remove_staging_dirs() diff --git a/tests/unit/gapic/gkehub_v1/test_gke_hub.py b/tests/unit/gapic/gkehub_v1/test_gke_hub.py index 8f10a97..5eefc81 100644 --- a/tests/unit/gapic/gkehub_v1/test_gke_hub.py +++ b/tests/unit/gapic/gkehub_v1/test_gke_hub.py @@ -34,8 +34,8 @@ from google.api_core import operations_v1 from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub.configmanagement.v1 import configmanagement_pb2 # type: ignore -from google.cloud.gkehub.multiclusteringress.v1 import multiclusteringress_pb2 # type: ignore +import google.cloud.gkehub.configmanagement_v1 as configmanagement_pb2 # type: ignore +import google.cloud.gkehub.multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore from google.cloud.gkehub_v1.services.gke_hub import GkeHubAsyncClient from google.cloud.gkehub_v1.services.gke_hub import GkeHubClient from google.cloud.gkehub_v1.services.gke_hub import pagers @@ -125,7 +125,25 @@ def test_gke_hub_client_service_account_always_use_jwt(client_class): ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) - use_jwt.assert_called_with(True) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.GkeHubGrpcTransport, "grpc"), + (transports.GkeHubGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_gke_hub_client_service_account_always_use_jwt_true( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) @pytest.mark.parametrize("client_class", [GkeHubClient, GkeHubAsyncClient,]) From 87e1f6f551fd8ccc0ec7ddceac86d1a5b7480678 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 11:54:03 +0000 Subject: [PATCH 7/8] add replacement in owlbot.py --- .../services/gke_hub/async_client.py | 4 +-- .../gkehub_v1/services/gke_hub/client.py | 4 +-- .../services/gke_hub/transports/grpc.py | 26 +++++++++---------- .../gke_hub/transports/grpc_asyncio.py | 26 +++++++++---------- google/cloud/gkehub_v1/types/feature.py | 8 +++--- google/cloud/gkehub_v1/types/membership.py | 2 +- google/cloud/gkehub_v1/types/service.py | 2 +- owlbot.py | 14 ++++++++++ 8 files changed, 50 insertions(+), 36 deletions(-) diff --git a/google/cloud/gkehub_v1/services/gke_hub/async_client.py b/google/cloud/gkehub_v1/services/gke_hub/async_client.py index 632ae32..d56e4b5 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/async_client.py +++ b/google/cloud/gkehub_v1/services/gke_hub/async_client.py @@ -47,8 +47,8 @@ class GkeHubAsyncClient: The GKE Hub service operates on the following resources: - - [Membership][google.cloud.gkehub.v1.Membership] - - [Feature][google.cloud.gkehub.v1.Feature] + - [Membership][google.cloud.gkehub_v1.Membership] + - [Feature][google.cloud.gkehub_v1.Feature] GKE Hub is currently only available in the global region. diff --git a/google/cloud/gkehub_v1/services/gke_hub/client.py b/google/cloud/gkehub_v1/services/gke_hub/client.py index ecca4ad..59f4467 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/client.py +++ b/google/cloud/gkehub_v1/services/gke_hub/client.py @@ -82,8 +82,8 @@ class GkeHubClient(metaclass=GkeHubClientMeta): The GKE Hub service operates on the following resources: - - [Membership][google.cloud.gkehub.v1.Membership] - - [Feature][google.cloud.gkehub.v1.Feature] + - [Membership][google.cloud.gkehub_v1.Membership] + - [Feature][google.cloud.gkehub_v1.Feature] GKE Hub is currently only available in the global region. diff --git a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py index 0d1dff5..0614912 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc.py @@ -41,8 +41,8 @@ class GkeHubGrpcTransport(GkeHubTransport): The GKE Hub service operates on the following resources: - - [Membership][google.cloud.gkehub.v1.Membership] - - [Feature][google.cloud.gkehub.v1.Feature] + - [Membership][google.cloud.gkehub_v1.Membership] + - [Feature][google.cloud.gkehub_v1.Feature] GKE Hub is currently only available in the global region. @@ -277,7 +277,7 @@ def list_memberships( # to pass in the functions for each. if "list_memberships" not in self._stubs: self._stubs["list_memberships"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/ListMemberships", + "/google.cloud.gkehub_v1.GkeHub/ListMemberships", request_serializer=service.ListMembershipsRequest.serialize, response_deserializer=service.ListMembershipsResponse.deserialize, ) @@ -303,7 +303,7 @@ def list_features( # to pass in the functions for each. if "list_features" not in self._stubs: self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/ListFeatures", + "/google.cloud.gkehub_v1.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) @@ -329,7 +329,7 @@ def get_membership( # to pass in the functions for each. if "get_membership" not in self._stubs: self._stubs["get_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GetMembership", + "/google.cloud.gkehub_v1.GkeHub/GetMembership", request_serializer=service.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) @@ -353,7 +353,7 @@ def get_feature(self) -> Callable[[service.GetFeatureRequest], feature.Feature]: # to pass in the functions for each. if "get_feature" not in self._stubs: self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GetFeature", + "/google.cloud.gkehub_v1.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) @@ -383,7 +383,7 @@ def create_membership( # to pass in the functions for each. if "create_membership" not in self._stubs: self._stubs["create_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/CreateMembership", + "/google.cloud.gkehub_v1.GkeHub/CreateMembership", request_serializer=service.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -409,7 +409,7 @@ def create_feature( # to pass in the functions for each. if "create_feature" not in self._stubs: self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/CreateFeature", + "/google.cloud.gkehub_v1.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -440,7 +440,7 @@ def delete_membership( # to pass in the functions for each. if "delete_membership" not in self._stubs: self._stubs["delete_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/DeleteMembership", + "/google.cloud.gkehub_v1.GkeHub/DeleteMembership", request_serializer=service.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -466,7 +466,7 @@ def delete_feature( # to pass in the functions for each. if "delete_feature" not in self._stubs: self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/DeleteFeature", + "/google.cloud.gkehub_v1.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -492,7 +492,7 @@ def update_membership( # to pass in the functions for each. if "update_membership" not in self._stubs: self._stubs["update_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/UpdateMembership", + "/google.cloud.gkehub_v1.GkeHub/UpdateMembership", request_serializer=service.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -518,7 +518,7 @@ def update_feature( # to pass in the functions for each. if "update_feature" not in self._stubs: self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/UpdateFeature", + "/google.cloud.gkehub_v1.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -550,7 +550,7 @@ def generate_connect_manifest( # to pass in the functions for each. if "generate_connect_manifest" not in self._stubs: self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest", + "/google.cloud.gkehub_v1.GkeHub/GenerateConnectManifest", request_serializer=service.GenerateConnectManifestRequest.serialize, response_deserializer=service.GenerateConnectManifestResponse.deserialize, ) diff --git a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py index 2b75938..09e3173 100644 --- a/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py +++ b/google/cloud/gkehub_v1/services/gke_hub/transports/grpc_asyncio.py @@ -43,8 +43,8 @@ class GkeHubGrpcAsyncIOTransport(GkeHubTransport): The GKE Hub service operates on the following resources: - - [Membership][google.cloud.gkehub.v1.Membership] - - [Feature][google.cloud.gkehub.v1.Feature] + - [Membership][google.cloud.gkehub_v1.Membership] + - [Feature][google.cloud.gkehub_v1.Feature] GKE Hub is currently only available in the global region. @@ -284,7 +284,7 @@ def list_memberships( # to pass in the functions for each. if "list_memberships" not in self._stubs: self._stubs["list_memberships"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/ListMemberships", + "/google.cloud.gkehub_v1.GkeHub/ListMemberships", request_serializer=service.ListMembershipsRequest.serialize, response_deserializer=service.ListMembershipsResponse.deserialize, ) @@ -312,7 +312,7 @@ def list_features( # to pass in the functions for each. if "list_features" not in self._stubs: self._stubs["list_features"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/ListFeatures", + "/google.cloud.gkehub_v1.GkeHub/ListFeatures", request_serializer=service.ListFeaturesRequest.serialize, response_deserializer=service.ListFeaturesResponse.deserialize, ) @@ -338,7 +338,7 @@ def get_membership( # to pass in the functions for each. if "get_membership" not in self._stubs: self._stubs["get_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GetMembership", + "/google.cloud.gkehub_v1.GkeHub/GetMembership", request_serializer=service.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, ) @@ -364,7 +364,7 @@ def get_feature( # to pass in the functions for each. if "get_feature" not in self._stubs: self._stubs["get_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GetFeature", + "/google.cloud.gkehub_v1.GkeHub/GetFeature", request_serializer=service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) @@ -396,7 +396,7 @@ def create_membership( # to pass in the functions for each. if "create_membership" not in self._stubs: self._stubs["create_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/CreateMembership", + "/google.cloud.gkehub_v1.GkeHub/CreateMembership", request_serializer=service.CreateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -422,7 +422,7 @@ def create_feature( # to pass in the functions for each. if "create_feature" not in self._stubs: self._stubs["create_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/CreateFeature", + "/google.cloud.gkehub_v1.GkeHub/CreateFeature", request_serializer=service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -455,7 +455,7 @@ def delete_membership( # to pass in the functions for each. if "delete_membership" not in self._stubs: self._stubs["delete_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/DeleteMembership", + "/google.cloud.gkehub_v1.GkeHub/DeleteMembership", request_serializer=service.DeleteMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -481,7 +481,7 @@ def delete_feature( # to pass in the functions for each. if "delete_feature" not in self._stubs: self._stubs["delete_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/DeleteFeature", + "/google.cloud.gkehub_v1.GkeHub/DeleteFeature", request_serializer=service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -509,7 +509,7 @@ def update_membership( # to pass in the functions for each. if "update_membership" not in self._stubs: self._stubs["update_membership"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/UpdateMembership", + "/google.cloud.gkehub_v1.GkeHub/UpdateMembership", request_serializer=service.UpdateMembershipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -535,7 +535,7 @@ def update_feature( # to pass in the functions for each. if "update_feature" not in self._stubs: self._stubs["update_feature"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/UpdateFeature", + "/google.cloud.gkehub_v1.GkeHub/UpdateFeature", request_serializer=service.UpdateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) @@ -567,7 +567,7 @@ def generate_connect_manifest( # to pass in the functions for each. if "generate_connect_manifest" not in self._stubs: self._stubs["generate_connect_manifest"] = self.grpc_channel.unary_unary( - "/google.cloud.gkehub.v1.GkeHub/GenerateConnectManifest", + "/google.cloud.gkehub_v1.GkeHub/GenerateConnectManifest", request_serializer=service.GenerateConnectManifestRequest.serialize, response_deserializer=service.GenerateConnectManifestResponse.deserialize, ) diff --git a/google/cloud/gkehub_v1/types/feature.py b/google/cloud/gkehub_v1/types/feature.py index 0f88891..0f91981 100644 --- a/google/cloud/gkehub_v1/types/feature.py +++ b/google/cloud/gkehub_v1/types/feature.py @@ -21,7 +21,7 @@ __protobuf__ = proto.module( - package="google.cloud.gkehub.v1", + package="google.cloud.gkehub_v1", manifest={ "Feature", "FeatureResourceState", @@ -175,7 +175,7 @@ class CommonFeatureSpec(proto.Message): r"""CommonFeatureSpec contains Hub-wide configuration informatio. Attributes: - multiclusteringress (google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2.FeatureSpec): + multiclusteringress (google.cloud.gkehub.multiclusteringress_v1.multiclusteringress_pb2.FeatureSpec): Multicluster Ingress-specific spec. """ @@ -205,7 +205,7 @@ class MembershipFeatureSpec(proto.Message): a single Membership. Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipSpec): + configmanagement (google.cloud.gkehub.configmanagement_v1.configmanagement_pb2.MembershipSpec): Config Management-specific spec. """ @@ -222,7 +222,7 @@ class MembershipFeatureState(proto.Message): for a single Membership. Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipState): + configmanagement (google.cloud.gkehub.configmanagement_v1.configmanagement_pb2.MembershipState): Config Management-specific state. state (google.cloud.gkehub_v1.types.FeatureState): The high-level state of this Feature for a diff --git a/google/cloud/gkehub_v1/types/membership.py b/google/cloud/gkehub_v1/types/membership.py index f1ea88d..67c3d98 100644 --- a/google/cloud/gkehub_v1/types/membership.py +++ b/google/cloud/gkehub_v1/types/membership.py @@ -19,7 +19,7 @@ __protobuf__ = proto.module( - package="google.cloud.gkehub.v1", + package="google.cloud.gkehub_v1", manifest={ "Membership", "MembershipEndpoint", diff --git a/google/cloud/gkehub_v1/types/service.py b/google/cloud/gkehub_v1/types/service.py index d0aec24..7c12ebd 100644 --- a/google/cloud/gkehub_v1/types/service.py +++ b/google/cloud/gkehub_v1/types/service.py @@ -22,7 +22,7 @@ __protobuf__ = proto.module( - package="google.cloud.gkehub.v1", + package="google.cloud.gkehub_v1", manifest={ "ListMembershipsRequest", "ListMembershipsResponse", diff --git a/owlbot.py b/owlbot.py index acb4962..30448e2 100644 --- a/owlbot.py +++ b/owlbot.py @@ -30,11 +30,23 @@ "multiclusteringress", ] + # rename google.cloud.gkehub.vX to google.cloud.gkehub_vX + s.replace( + [ + library / f"google/cloud/gkehub_{library.name}/**/*.py", + library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py", + ], + f"google.cloud.gkehub.{library.name}", + f"google.cloud.gkehub_{library.name}", + ) + + # rename dependencies google.cloud.gkehub.dep.vX to google.cloud.gkehub.dep_vX for dep in dependencies: s.replace( [ library / f"google/cloud/gkehub_{library.name}/**/*.py", library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py", + library / f"google/cloud/gkehub/{dep}_{library.name}/**/*.py", ], f"from google.cloud.gkehub.{dep}.{library.name} import", f"import google.cloud.gkehub.{dep}_{library.name} as" @@ -42,6 +54,8 @@ s.replace( [ + library / f"google/cloud/gkehub_{library.name}/**/*.py", + library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py", library / f"google/cloud/gkehub/{dep}_{library.name}/**/*.py", ], f"google.cloud.gkehub.{dep}.{library.name}", From 734916790d578b85fcd83c4798e46bb3c63b1ea7 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 2 Jul 2021 13:00:50 +0000 Subject: [PATCH 8/8] exclude google/cloud/gkehub/__init__.py --- google/cloud/gkehub/__init__.py | 84 --------------------------------- owlbot.py | 2 +- 2 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 google/cloud/gkehub/__init__.py diff --git a/google/cloud/gkehub/__init__.py b/google/cloud/gkehub/__init__.py deleted file mode 100644 index 3faab2a..0000000 --- a/google/cloud/gkehub/__init__.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 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 google.cloud.gkehub_v1.services.gke_hub.client import GkeHubClient -from google.cloud.gkehub_v1.services.gke_hub.async_client import GkeHubAsyncClient - -from google.cloud.gkehub_v1.types.feature import CommonFeatureSpec -from google.cloud.gkehub_v1.types.feature import CommonFeatureState -from google.cloud.gkehub_v1.types.feature import Feature -from google.cloud.gkehub_v1.types.feature import FeatureResourceState -from google.cloud.gkehub_v1.types.feature import FeatureState -from google.cloud.gkehub_v1.types.feature import MembershipFeatureSpec -from google.cloud.gkehub_v1.types.feature import MembershipFeatureState -from google.cloud.gkehub_v1.types.membership import Authority -from google.cloud.gkehub_v1.types.membership import GkeCluster -from google.cloud.gkehub_v1.types.membership import KubernetesMetadata -from google.cloud.gkehub_v1.types.membership import Membership -from google.cloud.gkehub_v1.types.membership import MembershipEndpoint -from google.cloud.gkehub_v1.types.membership import MembershipState -from google.cloud.gkehub_v1.types.service import ConnectAgentResource -from google.cloud.gkehub_v1.types.service import CreateFeatureRequest -from google.cloud.gkehub_v1.types.service import CreateMembershipRequest -from google.cloud.gkehub_v1.types.service import DeleteFeatureRequest -from google.cloud.gkehub_v1.types.service import DeleteMembershipRequest -from google.cloud.gkehub_v1.types.service import GenerateConnectManifestRequest -from google.cloud.gkehub_v1.types.service import GenerateConnectManifestResponse -from google.cloud.gkehub_v1.types.service import GetFeatureRequest -from google.cloud.gkehub_v1.types.service import GetMembershipRequest -from google.cloud.gkehub_v1.types.service import ListFeaturesRequest -from google.cloud.gkehub_v1.types.service import ListFeaturesResponse -from google.cloud.gkehub_v1.types.service import ListMembershipsRequest -from google.cloud.gkehub_v1.types.service import ListMembershipsResponse -from google.cloud.gkehub_v1.types.service import OperationMetadata -from google.cloud.gkehub_v1.types.service import TypeMeta -from google.cloud.gkehub_v1.types.service import UpdateFeatureRequest -from google.cloud.gkehub_v1.types.service import UpdateMembershipRequest - -__all__ = ( - "GkeHubClient", - "GkeHubAsyncClient", - "CommonFeatureSpec", - "CommonFeatureState", - "Feature", - "FeatureResourceState", - "FeatureState", - "MembershipFeatureSpec", - "MembershipFeatureState", - "Authority", - "GkeCluster", - "KubernetesMetadata", - "Membership", - "MembershipEndpoint", - "MembershipState", - "ConnectAgentResource", - "CreateFeatureRequest", - "CreateMembershipRequest", - "DeleteFeatureRequest", - "DeleteMembershipRequest", - "GenerateConnectManifestRequest", - "GenerateConnectManifestResponse", - "GetFeatureRequest", - "GetMembershipRequest", - "ListFeaturesRequest", - "ListFeaturesResponse", - "ListMembershipsRequest", - "ListMembershipsResponse", - "OperationMetadata", - "TypeMeta", - "UpdateFeatureRequest", - "UpdateMembershipRequest", -) diff --git a/owlbot.py b/owlbot.py index 30448e2..1ce6b4c 100644 --- a/owlbot.py +++ b/owlbot.py @@ -83,7 +83,7 @@ """the GKE cluster. For example: //container.googleapis.com/projects/my-""" ) - s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) + s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst","google/cloud/gkehub/__init__.py"]) s.remove_staging_dirs()